Forum Moderators: phranque
I have searched through the forum here but haven't been able to figure out my rewrite rule.
I have a script located at http://www.example.com/scripts/do_something.php
I'd like to strip all parameters from do_something.php so that:
http://www.example.com/scripts/do_something.php?name=filename&location=loc&blah=blah
301 redirects to
http://www.example.com/scripts/do_something.php
I do not, however, want any other scripts with query strings to be stripped, only do_something.php.
Thanks!
RewriteCond %{query_string} .
rewriterule (.*) http://www.example.com/$1? [R=301,L]
but this strips query strings from all files, not just the do_something.php file.
Then I tried:
RewriteCond %{query_string} .
rewriterule ^scripts/do_something.php?name=(.*) http://www.example.com/scripts/do_something.php$ [R=301,L]
And many more variations of the above two. I seem to create an infinite redirect often because I am redirecting from do_something.php with query strings to do_something.php without query strings.
RewriteRule ^/scripts/do_something\.php\?.+$ /scripts/do_something.php [R=301,L]
RewriteCond %{QUERY_STRING} .
RewriteRule ^scripts/do_something\.ph[b]p$[/b] http://www.example.com/scripts/do_something.ph[b]p?[/b] [R=301,L]
Jim