Reputation: 13
I got 2 urls that i want to change with htaccess should be easy but Im having a hard time with it:
index.php?id=Agenda
to /agenda.html
and
?id=Agenda
also to /agenda.html
Ive tried
RewriteRule ^(.*[^/])/?$ index.php?id=$1 [L,NC]
and some variations on it but I cant get it to work any advice?
Upvotes: 1
Views: 175
Reputation: 785316
You can use this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /(?:index\.php)?\?id=(.+?)\s [NC]
RewriteRule ^ %1.html? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^([^.]+)\.html$ ?id=$1 [L,QSA,NC]
Upvotes: 2