Htaccess File - Change Underscores To Hyphens For More Than Two Words In Url
I am trying to change all underscores to hyphens for my website. currently I have this code added to .htaccess file. RewriteBase / RewriteRule !\.(html|php)$ - [S=6] RewriteRule
Solution 1:
Rather than so many complex rules, you can use these two recursive rules to replace all underscore by hyphens:
RewriteEngine On
RewriteRule \.(html?|php)$ - [L,NC]
RewriteRule ^([^_]*)_+([^_]*)$ http://www.askapache.com/$1-$2 [L,R=301,NE]
RewriteRule ^([^_]*)_+(.*)$ $1-$2 [N,DPI]
Post a Comment for "Htaccess File - Change Underscores To Hyphens For More Than Two Words In Url"