apache 在使用Laravel/Inertia导航到路径时未找到资源

pu3pd22g  于 2023-10-23  发布在  Apache
关注(0)|答案(1)|浏览(120)

我已经在一个自托管的Ubuntu服务器上部署了一个带有Laravel 9,Inertia,Vue 3和Apache 2的Web应用程序。通过调用mydomain.de,我可以很容易地访问起始页。但是当我导航到域的任何路径时,例如mydomain.de/settings,我得到以下错误:

  1. Not Found - The requested URL was not found on this server
  2. Apache/2.4.41 (Ubuntu) Server at mydomain.de Port 443

例如,当我调用mydomain.de/index.php/settings时,我发现路径可以工作,但URL如下所示

  1. mydomain.de/index.php/index.php/settings

本地路由工作完美。
我的Apache配置中设置了allowing All

rewrite.loadmod已启用。

Apache服务已重新启动多次。
我还尝试了根文件夹和公共文件夹中的不同.htaccess文件。
以下是我的档案:

/etc/apache2/sites-available/mydomain.de.conf

  1. Listen 8081
  2. <VirtualHost *:80, *8081>
  3. ServerAdmin [email protected]
  4. ServerName mydomain.de
  5. ServerAlias www.mydomain.de
  6. DocumentRoot /var/www/mydomain/public
  7. <Directory /var/www/mydomain/public>
  8. Options Indexes FollowSymLinks MultiViews
  9. AllowOverride All
  10. Require all granted
  11. </Directory>
  12. ErrorLog ${APACHE_LOG_DIR}/error.log
  13. CustomLog ${APACHE_LOG_DIR}/access.log combined
  14. Redirect "/" "https://mydomain.de"
  15. RewriteEngine on
  16. RewriteCond %{SERVER_NAME} =www.mydomain.de [OR]
  17. RewriteCond %{SERVER_NAME} =mydomain.de
  18. RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R]
  19. </VirtualHost>

网址:http://www.mydomain/public/

  1. <IfModule mod_rewrite.c>
  2. <IfModule mod_negotiation.c>
  3. Options -MultiViews -Indexes
  4. </IfModule>
  5. Options +FollowSymLinks
  6. RewriteEngine On
  7. RewriteBase /mydomain/public/
  8. # Handle Authorization Header
  9. RewriteCond %{HTTP:Authorization} .
  10. RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  11. # Redirect Trailing Slashes If Not A Folder...
  12. RewriteCond %{REQUEST_FILENAME} !-d
  13. RewriteCond %{REQUEST_URI} (.+)/$
  14. RewriteRule ^ %1 [L,R=301]
  15. # Send Requests To Front Controller...
  16. RewriteCond %{REQUEST_FILENAME} !-d
  17. RewriteCond %{REQUEST_FILENAME} !-f
  18. RewriteRule ^ index.php [L]
  19. </IfModule>

routes/web.php

  1. <?php
  2. use Illuminate\Support\Facades\Route;
  3. use Inertia\Inertia;
  4. Route::get('/', function () {
  5. return Inertia::render('Start', [
  6. 'title' => 'Start'
  7. ]);
  8. });
  9. Route::get('/settings', function () {
  10. return Inertia::render('Settings', [
  11. 'title' => 'Einstellungen'
  12. ]);
  13. });

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

sy5wg1nm

sy5wg1nm1#

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

相关问题