我已经在一个自托管的Ubuntu服务器上部署了一个带有Laravel 9,Inertia,Vue 3和Apache 2的Web应用程序。通过调用mydomain.de
,我可以很容易地访问起始页。但是当我导航到域的任何路径时,例如mydomain.de/settings
,我得到以下错误:
Not Found - The requested URL was not found on this server
Apache/2.4.41 (Ubuntu) Server at mydomain.de Port 443
例如,当我调用mydomain.de/index.php/settings
时,我发现路径可以工作,但URL如下所示
mydomain.de/index.php/index.php/settings
本地路由工作完美。
我的Apache配置中设置了allowing All。
rewrite.loadmod已启用。
Apache服务已重新启动多次。
我还尝试了根文件夹和公共文件夹中的不同.htaccess文件。
以下是我的档案:
/etc/apache2/sites-available/mydomain.de.conf
Listen 8081
<VirtualHost *:80, *8081>
ServerAdmin [email protected]
ServerName mydomain.de
ServerAlias www.mydomain.de
DocumentRoot /var/www/mydomain/public
<Directory /var/www/mydomain/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect "/" "https://mydomain.de"
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mydomain.de [OR]
RewriteCond %{SERVER_NAME} =mydomain.de
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R]
</VirtualHost>
网址:http://www.mydomain/public/
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /mydomain/public/
# 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>
routes/web.php
<?php
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
Route::get('/', function () {
return Inertia::render('Start', [
'title' => 'Start'
]);
});
Route::get('/settings', function () {
return Inertia::render('Settings', [
'title' => 'Einstellungen'
]);
});
我做错了什么?如果有任何其他文件,我可以添加,使我的设置更清晰,不要犹豫,告诉我。
任何帮助都是感激不尽的。
1条答案
按热度按时间sy5wg1nm1#
我今天遇到了这个麻烦,我意识到我没有运行
sudo a2enmod rewrite
。对我有用的