Forum Moderators: phranque

Message Too Old, No Replies

.htaccess image redirect?

like php headers....?

         

ahmedtheking

8:44 pm on May 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, I want to move some files to another directory on my web server, but these files are images, that my clients link to. I have not got the time to go and change over 100 image urls, so is there a way i can get .htaccess file to do a mod_rewrite to point then image url to where it should be?

sitz

11:15 pm on May 9, 2005 (gmt 0)

10+ Year Member



If all your images are in one directory (or one of a few directories) you could use Redirect [httpd.apache.org] or RedirectMatch [httpd.apache.org]. If your requirements aren't met be these directives, mod_rewrite [httpd.apache.org] would be the way to go. Check out the links in the Forum Charter [webmasterworld.com], and this primer [webmasterworld.com] for starters.

JAB Creations

7:43 am on May 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Redirect permanent /image-01.jpg [example.com...]

Redirect permanent /image-02.jpg [example.com...]

Redirect permanent /image-03.jpg [example.com...]

Redirect permanent /image-04.jpg [example.com...]

If your image is at [example.com...] use the example above (in your .htaccess file). I don't know if you can use a short (relative) path for the redirect so I use the full path. If you set the redirect correctly paste the url of the redirected file and if it works the url will auto change.

If mess up your .htaccess file you will need to delete it until you can fix it. -a is the filter to show hidden files on FTP. If you can't figure it out, upload a totally blank .htaccess file and you'll be able to access your server again (via browser).

JAB Creations

7:43 am on May 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PS... this will work with ANY file and ANY TYPE.