Forum Moderators: phranque
I thought I'd left things long enough to rid Google of all the old URL's but I was wrong. There are now thousands and thousands of old URL's that show as unique topics in the SERPS but when you click on the link, my server just produces to the main main www.widgets.com mainpage... thousands and thousands of URL's all producing the same content. It's a dupe disaster.
(NOTE: my main page still ranks well in the SERPS (position 3 for main search term out of 2.5 million results)
How on Earth do I configure my server to produce genuine 404 headers for all those useless URL's? :(
... is an example of a non existant URL that Google won't drop. Anything after the question mark, no matter what you type, produces the homepage.
I had a long chat with my server support team. They explained to me that if this is a default of PHP rather than Apache and it's something a lot of people struggle to configure. He was not a PHP specialist and had no answer to my problem.
I need these old URL's to produce a genuine 404 error or I'm never going to be rid of these old URL's
RewriteCond %{QUERY_STRING} .
RewriteRule ^index\.php$ /this_file_does_not_exist.html? [L]
However, if you are also rewriting static URLs to dynamic URLs involving index.php, then you would need to make sure that only client requests --and not previously-rewritten requests-- are rewritten:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?[^\ ]+\ HTTP/
RewriteRule ^index\.php$ /this_file_does_not_exist.html? [L]
Jim
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.info$ [NC]
RewriteRule ^(.*)$ http://www.example.info/$1 [R=301,L]
RewriteCond %{QUERY_STRING} .
RewriteRule ^index\.php$ /this_file_does_not_exist.html? [L]
... Incidentally, a discovered a very strange thing during this. I removed the htaccess file completely for a few moments while I changed it and tested the canonical thing. I was amazed to see that even without the htaccess file, non www url's were still being redirected to www ones!?... very odd.
[edited by: jdMorgan at 8:09 pm (utc) on April 17, 2006]
[edit reason] Examplified. [/edit]