.htaccess apache 2.2到2.4更新

时间:2013-09-13 18:14:45

标签: php apache .htaccess

我们的主机最近将他们的apache服务器从2.2更新到2.4,现在我们不断收到500内部服务器错误,我们的错误日志显示为“RewriteCond:bad flag delimiters”。

我们的.htAccess文件看起来像这样。

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/views/.*$ #allows to access views folder and everything in it.
RewriteCond %{REQUEST_URI} !^test.php$ #allows to access views folder and everything in it.
RewriteCond %{REQUEST_URI} !^phonegapFunction.php$ #allows to access views folder and everything in it.
RewriteRule ^([a-zA-Z0-9æøå]*)\/?(\w*)\/?(.*)$ /app.php?team=$1&page=$2&value=$3 [L]

我们的主持人说我们需要将.htaccess文件更新为apache 2.4规范,但是我们在这方面遇到了问题,所以希望有人可以提供帮助。

提前致谢

1 个答案:

答案 0 :(得分:2)

这是我在Apache 2.2和2.4中获得的

使用.htaccess文件:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/views/.*$ #allows to access views folder and everything in it.
RewriteCond %{REQUEST_URI} !^test.php$ #allows to access views folder and everything in it.
RewriteCond %{REQUEST_URI} !^phonegapFunction.php$ #allows to access views folder and everything in it.
RewriteRule ^([a-zA-Z0-9æøå]*)\/?(\w*)\/?(.*)$ /app.php?team=$1&page=$2&value=$3 [L]

这是我在错误日志中得到的错误,对于这两个版本:

/var/www/localhost/htdocs/.htaccess: RewriteCond: bad flag delimiters

但如果我删除评论:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/views/.*$ 
RewriteCond %{REQUEST_URI} !^test.php$  
RewriteCond %{REQUEST_URI} !^phonegapFunction.php$
RewriteRule ^([a-zA-Z0-9???]*)\/?(\w*)\/?(.*)$ /app.php?team=$1&page=$2&value=$3 [L]

没有错误,我可以很好地路由到app.php。