Reputation: 1239
I wanna redirect wordpress page to a static page. The urls such as http://domain.com/?p=222 should be redirected to http://domain.com/222.html. For some reason the code from bellow doesn't work:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^?p=(.*)$ http://domain.com/$1.html [NC,L,R=301]
Why is it and what is the correct code?
Upvotes: 0
Views: 43
Reputation: 785146
RewriteRule
doesn't match query string. Use this rule instead:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^p=(\d+) [NC]
RewriteRule ^/?$ /%1.html [L,R=301]
Upvotes: 1