【问题标题】:Index.php rewrite fails after Apache 2.2 to 2.4 updateApache 2.2 到 2.4 更新后 Index.php 重写失败
【发布时间】:2015-11-02 16:30:01
【问题描述】:

我的 Kohana 3.3 项目的 .htaccess 文件是:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
  Order Deny,Allow
  Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

按照 Eric 的建议,我已将 htaccess 更新为以下内容:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files ".*">
  Require all denied
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php/$0 [PT]

我更新了虚拟主机以包括:

<Directory /srv/www/example.com/public_html/>
    Require all granted
</Directory>

我错过了什么吗?

【问题讨论】:

  • 您的 Apache 错误日志是怎么说的?
  • 你现在得到 404 了吗?
  • 你应该阅读httpd.apache.org/docs/2.4/upgrading.html关于允许拒绝部分
  • @Eric 谢谢错过那个 - 仍然得到 404。
  • 请用您的新规则更新主帖

标签: php apache .htaccess kohana


【解决方案1】:

修改htaccess

# Protect hidden files from being viewed
<Files .*>
  Require all granted
</Files>

并将 AllowOverride All 添加到虚拟主机配置中。

<Directory /var/www/example.com/public_html/>
    Require all granted
    AllowOverride All
</Directory>

【讨论】:

    猜你喜欢
    • 2013-09-18
    • 2017-10-11
    • 1970-01-01
    • 1970-01-01
    • 2017-03-04
    • 2020-02-26
    • 2014-12-15
    • 2015-08-31
    • 1970-01-01
    相关资源
    最近更新 更多