开发者

.htaccess redirection with chars manipulation

开发者 https://www.devze.com 2023-01-26 11:16 出处:网络
Is there an way I can use a regex to redirect (301) URLs int he .htacces in a way thatdomain.com/My_Name.html will be redirected to domain.com/my-name ?

Is there an way I can use a regex to redirect (301) URLs int he .htacces in a way that domain.com/My_Name.html will be redirected to domain.com/my-name ? Need to replace all _ with -, lower case the chars and subtract the ".html"


EDIT: I need to replace all _ chars, no matter how many of them are in the URL开发者_Python百科.


RewriteEngine on
RewriteRule ^(\w+)_(\w+)\.html$ ${tolower:$1}-${tolower:$2}

Not yet tested, but I'm pretty sure this will work.

0

精彩评论

暂无评论...
验证码 换一张
取 消