mod-rewrite - 重写不起作用(匹配多个)

标签 mod-rewrite ubuntu rewrite

抱歉标题不好。

我有以下我认为非常简单的规则:

RewriteRule ^(blog|articles|other)(/?)$ articles/?type=$1

然后我点击www.mysite.com/other
但是页面越来越 ?type 作为“文章”?!

在这里插入我挠头的照片。

最佳答案

您的规则将导致无限循环。用这个替换你的代码:

RewriteCond %{QUERY_STRING} ^$ [NC]
RewriteRule ^(blog|articles|other)(/?)$ articles/?type=$1 [L,QSA,NC]

由于目标 URI 也是 /articles/这将一次又一次地匹配条件模式,直到 Apache 用完 RewriteLimit 并抛出 500。

关于mod-rewrite - 重写不起作用(匹配多个),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18775218/

相关文章:

nginx - 如何使用 nginx 将多个 URL 映射到单个文件?

.htaccess - 从 URL 请求中删除 .php 文件扩展名

php - 用于创建 URL 的简单 PHP 应用程序,例如 <ROOT_URL>/twitter_username

c - (node v8plus)example.c :5:26: fatal error: sys/ccompile. h: 没有这样的文件或目录

IIS 重写 Url 到另一个域/PHP 应用程序和 SEO 优化

.htaccess - 在 htaccess 中重写 URL 时添加 .html?

wordpress - 子文件夹 WordPress 的 htaccess 冲突

apache - htaccess 重写为需要 www、https 和 ip

python - Selenium Page down by ActionChains

在 Ubuntu 上重新启动 Apache - 错误 "could not bind to address 0.0.0.0.80"