【问题标题】:.htaccess apache 2.2 to 2.4 update.htaccess apache 2.2 到 2.4 更新
【发布时间】:2013-09-18 12:25:12
【问题描述】:

我们的主机最近将他们的 apache 服务器从 2.2 更新到 2.4,现在我们不断收到 500 Internal Server Error,我们的错误日志显示“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 规范,但我们在执行此操作时遇到了问题,因此希望这里有人可以提供帮助。

提前致谢

【问题讨论】:

  • 这些 cmets 实际上是您的 htaccess 文件的一部分吗?
  • @JonLin 说的,.htaccess cmets 需要在自己的行上。
  • httpd.apache.org/docs/trunk/upgrading.html - 关于从 2.2 升级到 2.4 的 Apache 文档
  • @JonLin 是的,这些是 htaccess 文件的一部分,但我们已尝试删除它们,但错误消息没有任何变化。
  • 那么我真的看不出你的任何 RewriteConds 有什么问题。我建议一次将它们注释掉一个,直到错误消失,以隔离它是三个中的哪一个。

标签: php apache .htaccess


【解决方案1】:

这是我在 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

但如果我删除 cmets:

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。

【讨论】:

    猜你喜欢
    • 2015-11-02
    • 2015-08-31
    • 2016-04-11
    • 2017-10-11
    • 2012-12-15
    • 1970-01-01
    • 2014-06-16
    • 2016-01-19
    • 2023-03-05
    相关资源
    最近更新 更多