提问人:giovanikill 提问时间:8/31/2023 最后编辑:halfergiovanikill 更新时间:10/13/2023 访问量:103
Laravel “在此服务器上找不到请求的 URL”,但它存在于“web.php”上
Laravel 'The requested URL was not found on this server.', but it exists on 'web.php'
问:
每次我尝试访问我得到的路线时,除了路线。如果我将其他路线更改为 ,它会起作用。"The requested URL was not found on this server."
"/"
web.php
"/"
这是 apache:default.conf
<VirtualHost *:80>
ServerName website-project
DocumentRoot /var/www/website-project/public
<Directory /var/www/website-project>
Options Indexes FollowSymLinks
AllowOverride All
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]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
这是我的url变量:.env
APP_URL=http://localhost:8080
这些是路线:web.php
Route::get('/create', [AppointmentController::class, 'newAppointment'])->name('appointment.newAppointment');
Route::post('/create', [AppointmentController::class, 'createAppointment'])->name('appointment.createAppointment');
Route::get('/edit/{appointment}', [AppointmentController::class, 'editAppointment'])->name('appointment.editAppointment');
Route::get('/', [AppointmentController::class, 'index'])->name('appointment.index');
我应该注意,我正在容器上运行服务器。php:8.0-apache
我试过了:
- 激活。它显然打开了。
mod_rewrite
- 删除和添加所有和许多排列。
RewriteCond
RewriteRule
- 跑步和每次我做出任何改变。
php artisan route:clear
php artisan config:clear
- 多次重建容器。
- 更改所有文件的审核和所有权。
- 再次更改路由顺序和 url,如果它们使用 .
"/"
答:
0赞
giovanikill
8/31/2023
#1
如果有人在那里苦苦挣扎,我不得不放入 apache 的最后一行,因为在容器的 bash 中运行它不起作用,因为您需要重新启动服务器,从而删除更改。RUN a2enmod rewrite | service apache2 restart
dockerfile
评论
website-project
website-project.local