apache 404错误页面404错误页面

2skhul33  于 2023-03-13  发布在  Apache
关注(0)|答案(1)|浏览(171)

(我故意这样命名它,因为到目前为止我在stackoverflow中看到的其他建议要么不适用于我的情况,要么不起作用。)
我正在将一个可以正常工作的Yii 2应用从Ubuntu 14.04虚拟机迁移到22.04虚拟机,这是我单独构建的,而不是通过各种操作系统升级步骤来升级到当前版本。两个虚拟机上的PHP版本相同。漂亮的URLhttp://(server)/site/login返回404。Apache 2访问日志显示:

192.168.130.212 - - [06/Mar/2023:18:30:03 -1000] "GET /site/login HTTP/1.1" 404 487 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/110.0"
192.168.130.212 - - [06/Mar/2023:18:30:03 -1000] "GET /favicon.ico HTTP/1.1" 200 1450 "http://beretania/site/login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/110.0"

错误日志中没有任何内容。我尽可能地复制了服务器配置。代码本身,在GitHub中管理,应该是相同的。
来自配置

'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules' => [
        ],
    ],

.htaccess网站

# Requires FollowSymLinks to work; also turn on the REWRITE engine
<IfModule mod_rewrite.c>
   Options +FollowSymlinks
   RewriteEngine On
</IfModule>

# Unless explicit file or director exists, redirect all requests to Yii entry script
<IfModule mod_rewrite.c>
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule . index.php
</IfModule>

AddType application/octet-stream .txt

在这两种情况下启用的站点都称为dbos。
下面是dbos.conf

<VirtualHost *:80>
    ServerAdmin jmdemoor@localhost
    ServerName beretania
    DocumentRoot /var/www/dbos/web
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /var/www/dbos/web/>
        Options Indexes FollowSymLinks Multiviews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

相关,除了apache2.conf(我假设它已经被启用的站点dbos.conf覆盖了):

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
...
AccessFileName .htaccess

这是我得到的:

与生产虚拟机相同的url工作正常。有什么想法吗?
先谢了。

8mmmxcuj

8mmmxcuj1#

感谢Michal Hynčica。mod_rewrite未启用。

$ sudo a2enmod rewrite
$ sudo systemctl restart apache2

解决了。

相关问题