regex - 重定向 .htaccess - 删除 url 的最后一部分

标签 regex .htaccess redirect mod-rewrite

我需要重定向 url,例如:www.domain.com/xx/yy/itinerarwww.domain.com/xx/yy。 yy 的值可以是多种多样的。 我有

RewriteCond %{REQUEST_URI} (.*)itinerar

但我在使用 RewriteRule 时遇到了麻烦。

最佳答案

你可以使用这个重定向规则:

RewriteEngine On

RewriteRule ^(.*)/itinerar/?$ /$1 [L,NC,R=301]

关于regex - 重定向 .htaccess - 删除 url 的最后一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40130180/

相关文章:

.htaccess - URL重写如何添加额外条件

java - 零长度匹配是否结束匹配过程?

zend-framework - 如何使用 apache2 和 zend 创建多个虚拟主机

php - .htaccess 301 重定向,URL 有不同的标识符

asp.net-mvc - ASP.NET MVC 将非 WWW 重定向到 WWW 并重写为小写 URL

asp.net - 重定向到带有 true VS CompleteRequest 和安全线程的 endResponse 的页面

php - 如何在 preg_replace() 函数中使用 substr() 函数?

regex - Perl 中的正则表达式分组

php - 将链接替换为另一个链接

.htaccess - 使用 .htaccess 重写 URL