[英]Creating a regex redirect rule based on parameter in url
I'm trying to create a htaccess 302 redirect rule which should work as follows: 我正在尝试创建htaccess 302重定向规则,该规则应如下所示:
http://domain.com/projects/this_can_be_whatever/identifier_2/identifier_3/
redirect to: 重定向到:
http://domain.com/assignments/identifier_2_identifier_3/
So basically it removes this_can_be_whatever
and combines the last two identifiers / folders with an underscore instead of a "/". 因此,基本上,它会删除this_can_be_whatever
,并将最后两个标识符/文件夹与下划线而不是“ /”组合在一起。
Edit: I just noticed that my client has changed the links on their site :( I've updated the URL structure above. Sorry for this. 编辑:我刚刚注意到我的客户更改了他们网站上的链接:(我已经更新了上面的URL结构。对此很抱歉。
RewriteEngine on
RewriteRule ^projects/(?:.+)/(.+)/(.+)/$ http://domain.com/assignments/$1_$2/ [R=302,L]
should work 应该管用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.