Apache Regexp 500内部错误

时间:2014-04-05 11:19:46

标签: php regex apache codeigniter

我想重写所有传入的网址,例如:host/lang-EN/producthost/index.php?lang=lang-EN/product我想对所有不改变任何内容的网址执行此操作host/lang-EN/之后将其转发到{{1} }

这是我尝试过的:

host/index.php?lang=lang-EN/whatever was after lang-EN/

由Apache(上一版本)引发内部错误。我使用Codeigniter作为框架。

error.log中:

RewriteEngine On

RewriteRule     ^(.*)$               index.php/$1   [NC,L]
RewriteRule     ^index.php/(.*)/?$   index.php?lang=$1  [NC,L]

1 个答案:

答案 0 :(得分:0)

只需尝试将此/host/...重定向到/host/index.php...

RewriteRule     ^/?(?!index\.php)(.*)$         index.php?lang=$1   [NC,L]

(?!index.php)是负面预测,检查开头是否有index.php。因此,它不会触及像/index.php?lang=...这样的网址,以避免递归。