Reputation: 449
This is probably incredibly simple, but I've gone through several links and can't find the answer that I'm looking for.
My URL:
www.website.org/shows/index.php?id=1
Desired Rewrite:
www.website.org/shows/id/index.php
I know I need to use the RewriteRule
in .htaccess
for Apache, I just can't figure out how to get it to match then rewrite.
My failed attempt:
RewriteRule ^/shows/index.php?id=([0-9])$ shows/$1/index.php
Upvotes: 0
Views: 35
Reputation: 8736
Your rewrite rule should be like that:
RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^shows/index\.php$ /shows/%1/index.php
There is a very good official documentation, which explains how to access quesry sting in rewrite rules: https://simonecarletti.com/blog/2009/01/apache-query-string-redirects/
Upvotes: 1