mod_rewrite in action

After switching from blogspot to my own wordpress blog I noticed a lot of 404s. These were triggered by the url change, because initially the articles on blogspot had html extension at the end of url while on wordpress there wasn’t such thing. For example if initially the link was http://blog.getasysadmin.com/some-article.html now it become http://blog.getasysadmin.com/some-article/.

Quick fix via mod_rewrite, simply edit .htaccess from the root of the website and add this line after RewriteBase:

RewriteRule ^(.*)\.html$ $1/ [R=301,NC,L]

R=301 means Redirect with 301 code(moved permanently)
NC=no case or case insensitive
L=last rule

Your email address will not be published. Required fields are marked *