Web Hosting Talk







View Full Version : Image replacement on site...


Matth3wJL
01-12-2007, 09:27 PM
A user has an image hosted on my site. When I remove that image I want it to show my company image in its place. How is this done?

Thanks!

host2020
01-12-2007, 10:35 PM
The easiest way would just be to upload your logo in place of that file. Or you could use an .htaccess file (if you're using apache) to redirect that image to the new one.

This would be the content of the .htaccess:

Redirect /images/theoldimage.jpg http://mysite.com/mycompanyimage.jpg

Matth3wJL
01-14-2007, 04:34 PM
The easiest way would just be to upload your logo in place of that file. Or you could use an .htaccess file (if you're using apache) to redirect that image to the new one.

This would be the content of the .htaccess:

Redirect /images/theoldimage.jpg http://mysite.com/mycompanyimage.jpg

say i have a directory with 100 images that are all different extensions how would i make it so they all show up as one image as I specify?

Matth3wJL
01-14-2007, 04:35 PM
Im not sure but...

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^images/(.*) http://www.host.com/images/logo.gif [R=301,L]
</IfModule>

or is that incorrect

Matth3wJL
01-15-2007, 08:23 PM
anyone?

I am trying to get it so that if an image has a url on forums that shows an image.. if I remove tha timage they have showing on the forums from my server it will be replaced automatically by another image that I set.

foobic
01-15-2007, 08:58 PM
Try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^images images/replacement.jpg [L]

Matth3wJL
01-15-2007, 09:18 PM
Try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^images images/replacement.jpg [L]

How do I do this for multiple file names?

foobic
01-15-2007, 09:22 PM
Like that. It just redirects if the file requested doesn't exist. Change images to your own image directory path and replacement.jpg to the filename of your replacement image.

Matth3wJL
01-15-2007, 09:31 PM
Like that. It just redirects if the file requested doesn't exist. Change images to your own image directory path and replacement.jpg to the filename of your replacement image.

Does this go in the main dir..? Also just curious the image that is being removed is located in www.myhost.com/img/folder1/image.gif

The image I want it to display is www.myhost.com/images/logox.gif

How should the command look

foobic
01-15-2007, 10:31 PM
This should work from any directory, depending on what other redirects you may have (eg. seo-urls). If you already have .htaccess at the top level you can add these lines, otherwise put a new .htaccess in folder1:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/img/folder1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /images/logox.gif [L]