我已经开发了一个Laravel
项目,并且在我的本地主机上运行良好。我将其发布在具有Debian
操作系统的服务器上。我定义了一个虚拟主机,如下所示:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/Payment/public
<Directory /var/www/html/Payment>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</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>
这是我的web.php:
Route::get('/','mainController@index')->name('home');
Route::post('/payment','paymentController@payment')->name('payment');
存在一个问题,即找不到/ payment并返回The requested URL /payment was not found on this server
(404)错误。什么是resean?
我还运行了php artisan route:list
,并且定义了两条路由。
答案 0 :(得分:1)
更新Apache网站的配置文件,以将项目目录根目录定向到Laravel public
目录。
将<Directory /var/www/html/Payment>
替换为<Directory /var/www/html/Payment/public>