php - Not Found 在此服务器上找不到请求的 URL/about。 laravel 路由

标签 php laravel laravel-5 wamp wampserver

我收到一个错误提示

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/

相关文章:

php - 在 Laravel 中创建星级百分比

mysql - Laravel 5 迁移 - 外键约束失败

php - Laravel request()->fingerprint() 函数以及加密用户数据记录的可能性?

php - Joomla 数据库导入不起作用

php - 在PHP中使用CURL发布以 "@"开头的文本数据

PHP:下载 MySQL 表

php - 自动增量字段为零的播种表

涉及连字符的 PHP MySQL 语法错误

javascript - Laravel Mix 公共(public) block 和 vendor block

php - 外键约束的形成不正确 - Laravel