【发布时间】:2013-11-14 16:49:42
【问题描述】:
我正在尝试使用正确的 RewriteRule 或 RewriteCond 将下划线更改为连字符,除非下划线前面带有正斜杠。我制定了以下规则,这些规则将所有下划线更改为连字符,无论它前面是什么:
RewriteRule ^([^_]*)_+(.*)$ $1-$2 [E=underscores:Yes,N]
RewriteCond %{ENV:underscores} ^Yes$
RewriteRule (.*) http://%{HTTP_HOST}/$1 [R=301,L]
我需要修改什么以防止'/_'被更改为'/-'?
例子:
http://host/_test_location/_test_page 更改为
http://host/_test-location/_test-page不是
http://host/-test-location/-test-page
感谢您的帮助!
【问题讨论】:
标签: regex apache .htaccess mod-rewrite rewrite