Reputation: 154
How do I use the rewrite rule to replace the .php
wth /
For example:
search.php?k=background
to search/?k=background
What I have so far is:
RewriteRule ^search/?k=([a-zA-Z0-9_-]+)$ search.php/?k=$1
Upvotes: 1
Views: 77
Reputation: 11809
Here is another option:
RewriteEngine On
RewriteBase /
#Rule applies only when the script is search.php
RewriteCond %{REQUEST_URI} ^.*search\.php.*$
#Query will be automatically appended to search/
RewriteRule .* http://mydomain.com/search/ [L]
Will redirect:
http://mydomain.com/search.php?k=background
to
http://mydomain.com/search/?k=background
Upvotes: 2
Reputation: 143906
You need to remove the query string from your rewrite rule, that gets appended automatically:
RewriteRule ^search/?$ search.php [L]
Upvotes: 1