使用Laravel/Inertia导航到路径时找不到资源



我已经在自托管的Ubuntu服务器上部署了一个包含Laravel 9、Inertia、Vue3和Apache2的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

在本地,路由运行良好。

AllowOverrideAll是在我的Apache配置中设置的。

重写。加载模式已启用。

Apache服务已多次重新启动

我还在根文件夹和公用文件夹中尝试了不同的.htaccess文件。

这是我的文件:

/etc/apache2/可用站点/mydomain.de.conf

Listen 8081
<VirtualHost *:80, *8081>
ServerAdmin name@mydomain.de
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>

/var/www/mydomain/public/.htaccess

<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>

路由/web.php

<?php
use IlluminateSupportFacadesRoute;
use InertiaInertia;
Route::get('/', function () {
return Inertia::render('Start', [
'title' => 'Start'
]);
});
Route::get('/settings', function () {
return Inertia::render('Settings', [
'title' => 'Einstellungen'
]);
});

我做错了什么?如果有任何其他文件我可以添加,使我的设置更清晰,不要犹豫,告诉我。

感谢您的帮助。

我今天遇到了这个问题,我意识到我没有运行sudo a2enmod rewrite。对我有用

最新更新