Forum Moderators: phranque

Message Too Old, No Replies

RedirectMatch 410 / for a Query String URL

         

jk3210

4:11 am on Aug 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've done numerous "RedirectMatch 410 /foo.htm" redirects for various pages and they've all worked fine.

But, now I'm trying to issue a 410/gone to a request coming in from an external 302 redirect script that's requesting the url http*//www.mysite.com/?bcpid=909883157&bclid=909829140&bctid=752841807

But when I do this...

RedirectMatch 410 /?bcpid=909883157&bclid=909829140&bctid=752841807

...it doesn't issue a 410, it serves up the requested page as http*//www.mysite.com/?bcpid=909883157&bclid=909829140&bctid=752841807 (which doesn't exist)

Is there something special I have to do with that query string to get the 410 to work?

Thanks

jdMorgan

5:05 am on Aug 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you can't get this to work, I'd suggest using mod_rewrite instead of mod_alias.

Query strings are not handled as part of a URL, but rather as data attached to the URL to be passed to the resource *at* that URL. For this reason, support is poor in mod_alias, and requires a RewriteCond in mod_rewrite.

Jim

jk3210

6:06 am on Aug 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, Jim.

This appears to be working...

RewriteCond %{query_string} ^bcpid=909883157&bclid=909829140&bctid=752841807$
RewriteRule .* - [G]

jdMorgan

5:21 pm on Aug 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looks good. You might want to tighten-up the RewriteRule pattern, though, so that the RewriteCond won't be tested against each and every request to your server. If that query is only attached to one page URL, or an easily-defined group of URLs, then the RewriteRule pattern can be made specific to those URLs.

(By way of explanation, RewriteConds are only evaluated if the RewriteRule pattern matches, as documented in the mod_rewrite docs.)

Jim