apache - RedirectMatch 并包括 L 标志

标签 apache .htaccess mod-rewrite

需要一些帮助来添加 最后或 L 与 RedirectMatch 上的 301 一起标记。
我正在使用的代码如下所示,但只有 301 地位

RedirectMatch 301 ^/(folder1|folder2)($|/.*) http://fedmich.com/$1$2
我已经尝试过这些变体,但它们不起作用或有内部服务器错误。
RedirectMatch 301 ^/(folder1|folder2)($|/.*) http://fedmich.com/$1$2 #not working
RedirectMatch [R=301,L] ^/(folder1|folder2)($|/.*) http://fedmich.com/$1$2 #SERVER error
RewriteRule ^/(folder1|folder2)($|/.*) http://fedmich.com/$1$2 [R=301,L]    #No error, but not redirecting at all
我正在扫描 页眉在我制作的每个测试代码中,它不会被“缓存”并且不会被错误地重定向。
谢谢你们

引用

RedirectMatch http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirectmatch

FLAGS - http://httpd.apache.org/docs/current/rewrite/flags.html

最佳答案

您不能向 RedirectMatch 添加重写标志指示。重写内容是 mod_rewrite 的一部分,重定向内容是 mod_alias 的一部分。如果你想使用'L',你可以使用 mod_rewrite 代替

RewriteEngine On
RewriteRule ^(folder1|folder2)($|/.*) http://fedmich.com/$1$2 [L,R=301]

但我不明白为什么你需要 L 的根本问题国旗在这里。还有其他您不想应用的规则吗?

关于apache - RedirectMatch 并包括 L 标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21176095/

相关文章:

php - htaccess 301 重定向 - 删除查询字符串

apache - Mod_重写: Include query string when redirecting

regex - 如何使用请求的第一个字母使用 .htaccess 重写缓存子目录?

url - 如何密码控制对所有 url 的访问(apache 2 中的一个除外)

Android Studio JSON HTTP 应用程序崩溃

java - 如何使用 Apache HTTPClient 4.5 发送带有 JSON 参数的 POST。获取 415 不支持的媒体类型

.htaccess 用查询字符串重写 URL

php - 检测文件是否是PHP中没有mime类型的音频文件

reactjs - 使用 .htaccess 将除一个路由之外的所有路由转发到 react-router v4 的主页

.htaccess - 当我强行将 http 重定向到 https 时,它显示重定向了你太多次