troubleshooting Question

RewriteRule in .htaccess isn't working properly, how can this be fixed?

Avatar of thijs321
thijs321 asked on
Apache Web Server
2 Comments1 Solution179 ViewsLast Modified:
We've made some changes to the website including several url's. Since some other websites haven't updated their forms/url's yet they are linking to the wrong page. We've come up with the RewriteRule you can find in the Code Snippet, but it's not working at all.

Url at the old website:
http://website.com/search/?keywords=[...]
or
http://website.com/search/?keywords=[...]&place=[...]

And most of the time it has &button=Search at the end of it.

It needs to be rewrited to:
search.php?s=[keywords]&p=[place].
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
 
  RewriteRule ^search/\?keywords=([^&]*)(?:&place=([^&]*))?.*$ search.php?s=$1&p=$2 [R=301,NC]
 
  # Some other rules.
  # ...
</IfModule>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros