【问题标题】:Installing Laravel with WAMP - Routers not working使用 WAMP 安装 Laravel - 路由器不工作
【发布时间】:2015-01-04 16:49:35
【问题描述】:

我在 wampserver 下用 Composer 安装了 Laravel。

我的目录是:C:/wamp/www/laravel/firstProject

公共文件:C:/wamp/www/laravel/firstProject/public

所以当我尝试去 localhost/laravel/firstProject/public/projects 时

我收到此错误:“在此服务器上找不到请求的 URL /laravel/index.php。”

我输入时可以访问:localhost/laravel/firstProject/public/index.php/projects

我编辑了 httpd.conf 并取消了 mod_rewrite 的注释。

AllowOverride none 更改为AllowOverride all

还将RewriteBase /laravel/ 添加到 .htaccess 然后重新启动所有但仍然有同样的问题。

这是我的 routes.php 文件:

<?php

// show a static view for the home page (app/views/pages/home.blade.php)

Route::get('/', function() {
return View::make('pages.home');
});

Route::get('about', function() {
return View::make('pages.about');
});

Route::get('projects', function() {
return View::make('pages.projects');
});

Route::get('contact', function() {
return View::make('pages.contact');
});

这是我的 htaccess:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On
RewriteBase /laravel/
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

我知道这个问题被问了很多次,但我尝试了很多提供的解决方案,仍然一样..

感谢您的任何帮助或建议。

【问题讨论】:

  • 我还没有使用过 Laravel,但我敢打赌他们有一些例子或类似沙盒的东西。你试过了吗?这里也是最重要的。 htaccess 不是你的路由。最后 - 更改配置后您是否重新启动了 Apache?
  • 是的,我重启了,但还是一样。
  • 将您的 .htaccess 发布到 gist 或 pastebin。我看到有一个答案,所以在发布之前尝试一下。
  • 编辑并添加了 .htaccess,现在尝试一下
  • 那个解决了!谢谢@jibe_84!有很多人遇到这个问题,在我寻找解决方案时意识到..

标签: php .htaccess mod-rewrite laravel laravel-routing


【解决方案1】:

我在 .htaccess 文件中添加了以下行,它工作正常。

RewriteEngine On
RewriteBase /learn/

【讨论】:

    【解决方案2】:

    你试过这个 .htaccess 吗?

    Options +FollowSymLinks
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    

    这是来自http://laravel.com/docs/4.2/installation#pretty-urls的那个

    【讨论】:

      猜你喜欢
      • 2019-12-16
      • 2016-05-15
      • 1970-01-01
      • 1970-01-01
      • 2021-11-24
      • 1970-01-01
      • 2016-06-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多