Reputation: 27
I have the following code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=302]
I want to replace .html to /, but the code only remove the .html
Example: example.com/page.html to example.com/page/
Thank you!
Upvotes: 0
Views: 329
Reputation: 4917
You just need to simply add a /
at the end of /$1
.
So this line:
RewriteRule ^(.*)\.html$ /$1 [L,R=302]
becomes:
RewriteRule ^(.*)\.html$ /$1/ [L,R=302]
This will give you your desired URLs.
Complete working .htaccess
code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1/ [L,R=302]
Upvotes: 1