我想重写所有看起来像这样的网址:
test-domain.com/folderX/part-two/37-的 elementX
到
test-domain.com/certain-的 elementX - 特殊基团
更多例子:
test-domain.com/folderX/part-two/21-的 elementY
到
test-domain.com/certain-elementY-special-group
答案 0 :(得分:0)
RewriteEngine On
RewriteRule ^.*-([^-]*)$ /certain-$1-special-group
将同时映射
test-domain.com/folderX/part-two/21-element
test-domain.com/folderX/part-two/37-element
到
test-domain.com/certain-element-special-group
(您可以在此处测试:http://htaccess.madewithlove.be/)
如果您想特别匹配前缀:
test-domain.com/folderX/part-two
然后你可以使用:
RewriteEngine On
RewriteRule ^[^/]+/folderX/part-two/[\d]+-([^-]*)$ /certain-$1-special-group
(您也可以在此处测试:http://htaccess.madewithlove.be/)
答案 1 :(得分:0)
您可以使用:
RewriteEngine on
RewriteRule ^[^/]+/[^/]+/\d+-([^-]+)$ /certain-$1-special-group [R=301,L]
仅适用于以下网址:/ folder / folder / [nnn] - [name without - ]
为避免与其他现有文件或目录发生冲突,请在RewriteEngine on
之后添加:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f