我收到一个错误提示
Not Found
The requested URL /about was not found on this server.
我有这条路线
Route::get('/', 'megamitch@index');
Route::get('home', 'megamitch@index');
Route::get('about', 'megamitch@about');
Route::get('loan-products', 'megamitch@loanproducts');
Route::get('careers', 'megamitch@careers');
Route::get('contact', 'megamitch@contact');
如果我执行“php artisan route:list”,我可以看到那些路由确实存在。我在存在该问题的 wamp 服务器上运行(实时网络服务器上存在相同问题),但是如果我通过“php artisan serve”运行我的应用程序,所有页面都可以正常工作。有什么想法吗?
PS: 只有这条路线 "Route::get('/', 'megamitch@index');"有效。
最佳答案
听起来您的重写不起作用。如果您在 /about
之前将 index.php
添加到 URL 是否有效?
例如,yourdomain.com/about
将变为 yourdomain.com/index.php/about
如果您的重写不起作用,但您的 public
目录中有 .htaccess
文件,那么您可能需要在您的 apache 配置中允许覆盖。这是 WAMP 和 Laravel 的示例虚拟主机配置。
我已经标记了您需要更改的行。将第一个和第三个更改为指向网站目录中的 public
目录。然后将第二行更改为您在网站上使用的域名。
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/yourdomain/public" # Change this line
ServerName yourdomain.com # Change this line
<Directory "C:/wamp/www/yourdomain/public"> # Change this line
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All # This line enables .htaccess files
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
您需要重新启动 Apache 才能使这些设置生效。
关于php - Not Found 在此服务器上找不到请求的 URL/about。 laravel 路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32230130/