Forum Moderators: phranque

Message Too Old, No Replies

Prevent random string after .html file extension

from generating page - produce 404 instead.

         

Edouard_H

8:29 pm on Feb 26, 2005 (gmt 0)

10+ Year Member



I've pored over mod rewrite documentation and experimented a bit, but haven't been able to find anything that quite covers this. I would like to generate a 404 error for any requests that append the URL following the ".html".

Here's an example log entry which will go to www.mydomain.com/my_file_name.html when entered in the address bar:

/my_file_name.html&fr=ALmx0HCylV23MVmUcRTnLMIpCh665nkNw-0yFMsj8J1v-2TyyIGhnUIAAAAAAAAAAA

The URLs in question are dynamic and I already utilize mod rewrite for search engine friendly formatting. I'd like anything entered after ".html" in a URL to throw a 404.

I won't post what I've tried so far because I don't want anybody else to mistakenly attempt it as it either has no effect or a bad one ;) but a nudge in the right direction would be appreciated!

jdMorgan

12:35 am on Feb 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unless you post what you've got, it's a bit difficult to discuss it. Besides, our charter pretty much requires it.

But here's a nudge: For the case you posted, you'll need to examine %{QUERY_STRING} using RewriteCond, and then internally rewrite the requested URL to a non-existent 'trap' page to throw a 404. Alternately, you could throw a 403-Forbidden, or 301-redirect the requestor to the proper URL.

Jim