How do I use .htaccess RewriteRule to change underscores to dashes

前端 未结 1 1019
天命终不由人
天命终不由人 2020-12-06 15:17

I\'m working on a site, and its CMS used to save new page urls using the underscore character as a word seperator.

Despite the fact that Google now treats underscor

相关标签:
1条回答
  • 2020-12-06 15:28

    Just take the rule you were using already:

    RewriteRule ^([^_]*)_([^_]*_.*) $1-$2 [N]
    RewriteRule ^([^_]*)_([^_]*)$ /$1-$2 [L,R=301]
    

    …and put it before all other rewrite rules, and everything should work.

    Also, you used RewriteBase / twice. You can omit it the second time, since it’s already defined.

    0 讨论(0)
提交回复
热议问题