edenwax
VIP
v5 Beta Tester[M:5000]
Posts: 1,266
|
Post by edenwax on Sept 10, 2011 0:58:49 GMT
Using htaccess, how could I made a file url site.com/8885.png instead of site.com/images/8885.png ?
I looked it up online but it looks super complex and I can't figure it out.
|
|
Cam
Administrator
[M:5000]
Posts: 6,381
|
Post by Cam on Sept 10, 2011 4:33:22 GMT
You could put the image in the public_html couldn't you?
|
|
edenwax
VIP
v5 Beta Tester[M:5000]
Posts: 1,266
|
Post by edenwax on Sept 10, 2011 4:45:30 GMT
But thats messssssy. I like them in a nice folder.
|
|
Cam
Administrator
[M:5000]
Posts: 6,381
|
Post by Cam on Sept 10, 2011 4:46:55 GMT
|
|
edenwax
VIP
v5 Beta Tester[M:5000]
Posts: 1,266
|
Post by edenwax on Sept 10, 2011 5:01:57 GMT
Ehhh its more like website.com/randomnumberbetween1-6/pic.png
Yeah Ive been playing with file uploading and made something sick. Random name, random directory between 1-6, sweet security. Now I need to work on htaccess stuff to make the url look nicer.
|
|
russellr
Elite Level 1
[M:5000]
rCs?
Posts: 525
|
Post by russellr on Sept 15, 2011 17:17:36 GMT
Do you know all the urls or do you want it to create the redirect automatically?
A static option would be along the lines of:
RewriteEngine on
RewriteRule ^img1.png$ images/img1.png RewriteRule ^img2.png$ images/img2.png RewriteRule ^img3.png$ images/img3.png
but dynamic would be slightly different and shorter.
|
|
edenwax
VIP
v5 Beta Tester[M:5000]
Posts: 1,266
|
Post by edenwax on Sept 16, 2011 19:15:00 GMT
Ehhh the redirect automatically would be ideal.
|
|
edenwax
VIP
v5 Beta Tester[M:5000]
Posts: 1,266
|
Post by edenwax on Sept 22, 2011 19:13:53 GMT
*le bump*
|
|
|
Post by echnaret on Sept 24, 2011 5:10:34 GMT
I have a few questions. First, do you want to redirect everything in said folder(s), or just images? Will the folder(s) contain anything besides images? Also, I am confused: will the images be stored in one folder, or multiple? If multiple, how do you plan on differentiating between site.com/f1/img.gif and site.com/f2/img.gif?
|
|
edenwax
VIP
v5 Beta Tester[M:5000]
Posts: 1,266
|
Post by edenwax on Sept 24, 2011 16:54:49 GMT
No, just images. Yeah I was hoping to use multiple folders buuuut if thats not possible I'll just use a different method. (one folder )
|
|
|
Post by echnaret on Sept 26, 2011 1:00:05 GMT
What is the purpose of having multiple folders?
If everything is in one folder, you might try something like
RewriteRule ^(.+)\.jpg$ images/$1.jpg RewriteRule ^(.+)\.gif$ images/$1.gif RewriteRule ^(.+)\.png$ images/$1.png In theory (I didn't test it), that should take all images of type jpg, gif, or png (with a file name of at least one character) and rewrite the file name so it is located in the images/ folder.
|
|
edenwax
VIP
v5 Beta Tester[M:5000]
Posts: 1,266
|
Post by edenwax on Sept 26, 2011 6:41:49 GMT
There isnt a purpose really, I just wanted to test to see if I could do it. lol Thanks though! I'll give it a test now
|
|
|
Post by echnaret on Sept 26, 2011 16:11:33 GMT
I suppose, if you really wanted to, you could create a folder for each member on a site. However, the reason why it's not possible is because there would be no way to differentiate between two different pictures in two different folders with the same filename. You might be able to do something like this:
RewriteRule ^01(.+)\.jpg$ images01/$1.jpg RewriteRule ^02(.+)\.jpg$ images02/$1.jpg RewriteRule ^03(.+)\.jpg$ images03/$1.jpg which would (in theory), convert example.com/01image.jpg into example.com/images01/image.jpg.
Before you do that, though, you need to sit down and ask yourself, "is this really contributing something positive, or just making things overly complex for the sake of complexity?" In the above case, it would be far easier just to create folders with a short name ("01", "02", "03") and not bother with rewrites at all.
|
|
edenwax
VIP
v5 Beta Tester[M:5000]
Posts: 1,266
|
Post by edenwax on Sept 27, 2011 18:34:41 GMT
Oh its definitely making it more complex Like I said, its just something I was testing. I dont really need it to do that, and therefor only need a minor .htaccess rewrite.
|
|
edenwax
VIP
v5 Beta Tester[M:5000]
Posts: 1,266
|
Post by edenwax on Oct 1, 2011 1:58:13 GMT
Also
RewriteEngine on
RewriteRule ^(.+)\.jpg$ i/$1.jpg RewriteRule ^(.+)\.gif$ i/$1.gif RewriteRule ^(.+)\.png$ i/$1.png RewriteRule ^(.+)\.psd$ i/$1.psd RewriteRule ^(.+)\.txt$ i/$1.txt RewriteRule ^(.+)\.css$ i/$1.css
Gives me Internal Server Errors! D:
Nevermind, forgot to give .htaccess file the permissions.
|
|