
我在 WSL2/Ubuntu 上使用 Apache 2.4.41。
我有一個 laravel 項目,安裝了 Voyager。
我還使用虛擬主機(vh)。
存取應用程式 URLhttp://myapp
有效。但是 - Voyager 應用程式http://myapp/admin
失敗並出現 404 錯誤。
我的VirtualHost
文件是:
<VirtualHost *:80>
ServerName myapp
DocumentRoot /var/www/myapp/public
<Directory "/var/www/myapp/public">
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我的.htaccess
文件是:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
答案1
您的 DocumentRoot 是 /var/www/myapp/public。
管理員是在該路徑下嗎?如果沒有,那麼您需要在 Apache 配置中為其定義一個別名:
Alias /path/to/admin "/var/www/myapp/public/admin"
如果它已經在公共路徑下,我會仔細檢查 Apache 日誌和指派給管理頁面的 Linux 權限。