Forum Moderators: phranque

Message Too Old, No Replies

I want unknown paramaters of dynamic site to return 404>?

         

fsmobilez

12:59 pm on Feb 11, 2009 (gmt 0)

10+ Year Member



My site is generating dynamic links and it is showing content for any url which is typed in internet explorer/

Let say if i type

www.example.com
or
www.example.com/anything=?

or any other parameter after "/"

and same is with dynamic script

www.example.com/myscript/post=1
or
www.example.com/mysript/post=1?anyparameter

i there any way to produce 404 error when any extra string is typed in url. and how can i go for it>>?

Thanks for ur time.

jdMorgan

2:06 pm on Feb 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use Apache mod_rewrite to generate a 301-Moved Permanently redirect to that same URL, but with the query string removed. You could also generate a 404, but that may result in the loss of some visitors, and is an unnecessary risk.

The critical factor here is whether your site (or your control panel, stats program, or domain manager, etc.) actually uses any query strings. If not, then the code is simple. But if you do use *some* query strings, then either the mod_rewrite code must contain the logic (the "knowledge") needed to determine a valid versus invalid query string, or you must pass all query strings to your script, let it determine whether the query is valid, and if not, generate a 301 (or 404) server response.

Jim