Apache/2.4.6 更新导致 404 错误

Apache/2.4.6 更新导致 404 错误

我正在运行一个 ec2 ubuntu 实例,我决定今天将我的 PHP 更新到 5.5.7,不幸的是它也触发了 apache 更新,这导致我出现很多错误,最大的错误是我的重写规则不再被命中,我相信这与 .conf 更改有关。

我的网站配置文件(是的,我的前端和后端网站共享相同的.conf,有点懒,但是曾是方便的。

<VirtualHost *:80>
  DocumentRoot /var/www/hivetracking-front/checkout/hive-tracking/public/
  ServerName hivetracking.com
  ServerAlias www.hivetracking.com
  SetEnv _ENV production

        <Directory />
                DirectoryIndex index.phtml
                RewriteEngine On
                LogLevel alert rewrite:trace6
                Options Indexes FollowSymLinks
                AllowOverride All
        </Directory>


        ErrorLog /var/www/hivetracking-front/error.log


        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        CustomLog /var/www/hivetracking-front/access.log combined
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot /var/www/hivetracking-back/checkout/hive-tracking-api/public
  ServerName api.hivetracking.com
  SetEnv _ENV production

        <Directory />
                DirectoryIndex index.php
                RewriteEngine On
                LogLevel alert rewrite:trace6
                Options Indexes FollowSymLinks
                AllowOverride All
        </Directory>


        ErrorLog /var/www/hivetracking-back/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        CustomLog /var/www/hivetracking-back/access.log combined
</VirtualHost>

我的 API 的 .htaccess 文件:

RewriteEngine on
ServerSignature On
DirectoryIndex index.php
Options Indexes FollowSymLinks


<FilesMatch "\.(ico|pdf|flv)$">
    Header set Cache-Control "max-age=29030400, public" #1 YEAR
</FilesMatch>
<FilesMatch "\.(xml|txt|css|jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=172800, proxy-revalidate" #1 WEEK
</FilesMatch>
<FilesMatch "\.(html|htm|php|js)$">
    Header set Cache-Control "max-age=60, private, proxy-revalidate" #2 DAYS
</FilesMatch>


# system/session
RewriteRule ^([-A-Za-z0-9]+)/([-A-Za-z]+)$ index.php?__module=$1&__action=$2 [L,QSA]

# teams/something/123456
RewriteRule ([-A-Za-z0-9]+)/([-A-Za-z0-9]+)/([0-9a-fA-F]{24}+)$ index.php?__module=$1&__action=$2&id=$3 [L,QSA]

# teams
RewriteRule ^([-A-Za-z0-9]+)$ index.php?__module=$1&__action=index [L,QSA]

# teams/123456
RewriteRule ([-A-Za-z0-9]+)/([0-9a-fA-F]{24}+)$ index.php?__module=$1&__action=index&id=$2 [L,QSA]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

即将http://api.mydomain.com/client导致 404 转到http://api.mydomain.com/index导致 404 转到http://api.mydomain.com/index.php加载文件

非常感谢您的帮助!


编辑

我通过从 .htaccess 中删除这些内容解决了这个问题

<FilesMatch "\.(ico|pdf|flv)$">
    Header set Cache-Control "max-age=29030400, public" #1 YEAR
</FilesMatch>
<FilesMatch "\.(xml|txt|css|jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=172800, proxy-revalidate" #1 WEEK
</FilesMatch>
<FilesMatch "\.(html|htm|php|js)$">
    Header set Cache-Control "max-age=60, private, proxy-revalidate" #2 DAYS
</FilesMatch>

我不知道为什么我花了 8 个小时进行调试来追踪这个问题,但却没有记录错误。

答案1

在配置文件中搜索 AllowOverride 的所有示例。很可能已添加某些内容来替换上述配置中的内容。

其次,在 VirtualHost 的配置中,将 Directory 语句替换为您的文档根目录:

    <Directory /var/www/hivetracking-front/checkout/hive-tracking/public>
            DirectoryIndex index.php
            RewriteEngine On
            LogLevel alert rewrite:trace6
            Options Indexes FollowSymLinks
            AllowOverride All
    </Directory>

这将有助于确保其他东西不会覆盖 AllowOverride 设置。

相关内容