【问题标题】:Not Found The requested URL /about was not found on this server. laravel routes未找到 在此服务器上未找到请求的 URL /about。 laravel 路由
【发布时间】:2015-11-20 16:47:51
【问题描述】:

我说错了

找不到

在此服务器上找不到请求的 URL /about。

我有这条路线

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 服务器上运行(在实时 Web 服务器上存在相同问题),但是如果我通过“php artisan serve”运行我的应用程序,所有页面都可以工作。有什么想法,帮忙?

PS:只有这条路线“Route::get('/', 'megamitch@index');”有效。

【问题讨论】:

  • /index.php/about 有效吗?如果是这样,那么您的 apache 配置不会重写 URL。
  • 是的,它可以工作,我将如何配置 apache 配置以便它会重写 url 或修复什么?

标签: php laravel laravel-5 wamp wampserver


【解决方案1】:

听起来你的重写不起作用。如果在/about 之前的 URL 中添加index.php 是否有效?

例如,yourdomain.com/about 将变为 yourdomain.com/index.php/about

如果您的重写不起作用,但您的.htaccess 目录中有.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 才能使这些设置生效。

【讨论】:

  • 我在 /pulic/ 上缺少解决问题的 httaccess。
  • 这个解决方案(为虚拟主机启用 mod_rewrite)对我有用:askubuntu.com/a/423549/493153
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-11-28
  • 2019-03-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-25
相关资源
最近更新 更多