1
votes

I've just changed my permalinks in WordPress Permalink Settings.

The old post links were like that,

http://www.example.com/postname.html

Now new links are

http://www.example.com/postname/

I want to redirect all OLD post URL to new Permalink structure, since i am getting 404 errors at old links.

How do i redirect all .html posts to new non .html posts with .htaccess?

My Present .htaccess rules are:


    # BEGIN WordPress  
    <IfModule mod_rewrite.c>  
    RewriteEngine On  
    RewriteBase /  
    RewriteRule ^index\.php$ - [L]  
    RewriteCond %{REQUEST_FILENAME} !-f  
    RewriteCond %{REQUEST_FILENAME} !-d  
    RewriteRule . /index.php [L]  
    </IfModule>  
    # END WordPress

Thanks for your time and answers!

1

1 Answers

1
votes

EDIT: Try this as your .htaccess. I've just tested this on my dev environment and it works perfectly.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule (.+)\.html?$ http://www.example.com/$1/ [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress