Forum Moderators: phranque

Message Too Old, No Replies

Image Not Found Replacement .

Image Not Found Replacement ..

         

xdrive

2:20 pm on Jul 18, 2011 (gmt 0)

10+ Year Member





Hello .

I have more than 600.000 images uploded on my site ... these images are in a lot of pages on the web .
Now I delete 400.000 of them .. I'd like to replace the deleted images on these pages with another image called nophoto.gif ...

I tied a lot of codes on my htaccess not working ...

this is my site htaccess :


# Comment the following line (add '#' at the beginning)
# to disable mod_rewrite functions.
# Please note: you still need to disable the hack in
# the vBSEO control panel to stop url rewrites.
RewriteEngine On

# Some servers require the Rewritebase directive to be
# enabled (remove '#' at the beginning to activate)
# Please note: when enabled, you must include the path
# to your root vB folder (i.e. RewriteBase /forums/)
# RewriteBase /

# RewriteCond %{HTTP_HOST} ^www.alhnuf\.com$ [NC]
# RewriteRule ^(.*)$ http://alhnuf.com/$1 [R=301,L]

RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]

RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|vbseo_sitemap)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ vbseo.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(admincp|modcp|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ vbseo.php [L,QSA]





Please help me .

lucy24

3:49 pm on Jul 18, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Rule #2: No matter how obvious it is to you, don't say "it doesn't work". Say how it doesn't work. If nothing happens at all, say so. If it brings your site crashing to a halt, say so. If it brings up the wrong file, say so.

You've got your RewriteEngine On line. That was the first thing to check for. Do you have a pre-existing htaccess that has worked for other purposes? If not, you may need to check with your host and make sure you're allowed to have your own htaccess. (In www terms, "not allowed" means that it's ignored by the server.)

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(admincp|modcp|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ vbseo.php [L,QSA]


As written, this means:
Condition 1: the request is not an existing file
Condition 2: the request is not an existing directory
Condition 3: the requested file or directory is not in any of the named directories: admincp, modcp etc.
Rule: Any request meeting these conditions will be served instead with the top-level file vbseo.php

Is that what it is intended to mean? In particular, did you intend the rule to include requests for non-image files? The expected form for replacing images would be something like

RewriteRule \.(jpe?g|gif|png)$ nophoto.gif [NC,L]


You do not need QSA, since the rule does not mention query strings; existing queries are reappended by default. It is possible you do need ? at the end of your target to delete any existing query string, but what would a query string be doing after an image filename anyway?

xdrive

4:56 pm on Jul 18, 2011 (gmt 0)

10+ Year Member



thank you very much ... it's working now for all files on the folder ..

How can I let it work for only deleted ones ?

lucy24

10:14 pm on Jul 18, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Uh-oh. Do you still have the

RewriteCond %{REQUEST_FILENAME} !-f

line? That ought to constrain the rule to files that don't exist.

.htaccess cannot tell the difference between files that you've deleted and files that never existed, unless you tell it specific names or directories to look for. I suppose it's too much to hope that when you deleted 400,000 images you always deleted complete directories. It would definitely make everything run faster if the server didn't have to leaf through 200,000 files on each request.