Redirecting .html to non .html pages using .htaccess code

htaccess
redirection
without-plugin

#1

If you have a website with URLs like example.com/hello-world.html and if you want to redirect that to example.com/hello-world/, then you can try the below mentioned code. Copy/paste this into your .htaccess file. Make sure you replace example.com with your own URL.

RedirectMatch 301 ^/([^/]+).html$ http://example.com/$1

This should work fine, and if your website has ‘https’ instead of ‘http’, do change that as well. :slight_smile:

Update - If the above code is not working for your website, you can try these instead:

RedirectMatch 301 ^/([^/]+)/([^/.]+).html$ /$1/$2/
RedirectMatch 301 ^/([^/]+)/([^/]+)/([^/.]+).html$ /$1/$2/$3/


HTACCESS useful Rewrite Codes 2017