redirect/ %category%/%postname%.html to /%category%/%postname%

Question

My site was first built with html/css in 2000, and when I rebuilt it with WordPress in 2012, I kept the .html extension in the interest of keeping the same URLs. I’d like to get rid of it now and redirect the old html pages to the new extension-less pages.

My current permalink structure is:
/%category%/%postname%.html

I’d like it to be:
/%category%/%postname%

To do that, I tried deleting “.html’ from the end of the permalink structure, then saving permalinks. Then, I put this in my .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html

But it doesn’t work — pages just give me 404 errors that way.

I took a look at the Yoast permalink redirection tool, but that only redirects to /%postname% — I’m not sure if it’s possible to modify the outputted rule to add the category before the postname.

0
quantaws 3 years 0 Answers 46 views 0

Leave an answer