views:

360

answers:

1

I have URLs with lots of parameters, here is an example that looks like this:

http://www.mysite.com/profile?reset=1&force=1&gid=9&custom%5F18=BS+Forestry%2C+University+of+Kentucky

I would like to do a RewriteRule that redirects any request containing the string:

&custom

To a static HTML page such as:

http://www.mysite.com/foo.html

Can someone tell me if/how this is possible?

Thanks a lot!

+2  A: 

This should do the trick:

RewriteCond %{QUERY_STRING}  (^|&)custom(&|$)
RewriteRule ^(.*)$ http://www.mysite.com/foo.html [R]
brianreavis
brianreavis
graciasyou are a kind person
Stoob
QUESTION: this doesn't appear to work. I copied your info verbatim, changing only my domain. Nothing changed. I put the code near the top of the .htaccess file above all other ReWriteRules??
Stoob
Add the `L` modifier, so the end looks like this: [R,L]. That'll fix the problem. (The L modifier will tell Apache to ignore the rules that you have below.)
brianreavis