Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite n query strings

         

canzi

9:58 pm on May 6, 2008 (gmt 0)

10+ Year Member



Hi All

i have googled about query strings and still can't find a solution, i was hoping someone here could point me in the right direction :)

i have the URL's
http://proxy.example.com/errors/blocked.html?Time=24/Apr/2008:15:08:42%20+1000&ID=0002943691&
Client_IP=10.0.0.13&User=-&Site=example.au&URI=mddail/&Status_Code=503&Decision_Tag=OTHER&
URL_Cat=nc&WBRS=dns&DVS_Verdict=0&DVS_ThreatName=-
http://proxy.example.com/errors/blocked.html?Time=30/Apr/2008:14:38:25%20+1000&ID=0004244428&
Client_IP=10.0.0.13&User=-&Site=example.com.au&URI=&Status_Code=403&Decision_Tag=BLOCK_WEBCAT-DefaultGroup&
URL_Cat=Game&WBRS=-&DVS_Verdict=-&DVS_ThreatName=-

i would like to use mod_rewrite to redirect to a static page that represents the error based on &URL_Cat=xyz&WBRS=xyz

im trying
rewriteEngine on
RewriteBase /errors/
rewriteCond %{query_string} ^URL_Cat=nc&WBRS=dns$
rewriteRule ^errors$ [proxy.example.com...] [R=301,L]
rewriteCond %{query_string} ^URL_Cat=adult&WBRS=$
rewriteRule ^errors$ [proxy.example.com...] [R=301,L]

but obviously it isn't working for me, Id appreciate any help you can give me with this and thank you in advance

cheers
Steve

[edited by: jdMorgan at 12:28 am (utc) on May 8, 2008]
[edit reason] de-linked and tidied-up URLs [/edit]

jdMorgan

12:25 am on May 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to mind the meaning and usage of regular-expressions pattern anchoring. See the regular-expressions tutorial cited in our forum charter (link at top of this page).

RewriteEngine on
#
RewriteCond %{QUERY_STRING} &?URL_Cat=nc&WBRS=dns&?
RewriteRule ^errors/ http://proxy.example.com/errors/pagenotfound.html? [R=301,L]
#
RewriteCond %{QUERY_STRING} &?URL_Cat=adult&WBRS=
RewriteRule ^errors/ http://proxy.example.com/errors/adult-education.html? [R=301,L]

I'm not sure precisely how you intend this to work, but be aware that if you return a 301-Moved Permanently status code to a search engine, that it will not handle that as an error, and will continue to request the "bad" URL and list it in search results. Check the results of using the code above using an on-line server headers checker, or the "Live HTTP Headers" add-on for Firefox/Mozilla browsers. If you get a 301 response on your error pages, then you will need to re-design your error handling method.

Jim

[edited by: jdMorgan at 12:29 am (utc) on May 8, 2008]

TheMadScientist

2:51 pm on May 8, 2008 (gmt 0)

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



but be aware that if you return a 301-Moved Permanently status code to a search engine, that it will not handle that as an error, and will continue to request the "bad" URL and list it in search results.

The way I usually handle this is to make sure I set the header with PHP (or a scripting lang.) to make sure after the 301 is served, SEs are served a proper Error message, rather than a 301 to a 200.

It is not necessarily ideal, but should get the job done. The thing to avoid is a 301 to a 200, and absolutely avoid a 301 to a 302 (incorrect ErrorDocument reference) to a 200 page found.

canzi

12:36 am on May 9, 2008 (gmt 0)

10+ Year Member



Thanks guys working great
i had to change RewriteRule ^errors/ to RewriteRule ^(.*)$
is this ok?

this is just an internal service that wont be googled, it it to provide meaningful error pages to security device we have

Steve