【问题标题】:Laravel Route not working with WampLaravel Route 不适用于 Wamp
【发布时间】:2013-03-14 11:33:01
【问题描述】:

正如标题所述,我无法让我的网站重定向。我已经尝试了几次,但即将失败。

我的.htaccess文件如下:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php [L]

我将此文件放在 www/Laravel/public 文件夹以及 www 目录中

  • mod_rewrite 已启用
  • AllowOverride 设置为全部

我的主机文件如下

127.0.0.1       localhost

这是 routes.php 中包含的路由代码

Route::get('authors', array('uses'=>'authors@index'));

我有一个名为 authors.php 的控制器,这里是代码

class Authors_Controller extends Base_Controller {
public $restful = true;
public function get_index () {      
    return View::make('authors.index');}
}

我使用的是 Windows 7 Ultimate。我要炸掉我的脑袋了。请帮帮我,我很烂。

【问题讨论】:

  • 您是否还介意把系统错误输出的内容..
  • [Sun Mar 24 20:19:47 2013] [error] [client 127.0.0.1] 文件不存在:E:/wamp/www/Laravel/public/authors
  • 检查您的视图文件是否存在或控制器中的路由是否设置正确
  • 是的,据我所知。作者索引
  • 您用来访问此路由的完整 URL 是什么?

标签: php mod-rewrite routes wamp laravel


【解决方案1】:

您需要设置一个指向您的公共目录的虚拟主机... 在 httpd.conf 文件中。

可以在 Apache 菜单下找到...

就这样……

<VirtualHost *:80>
DocumentRoot c:\wamp\www\laravel\public
ServerName testing.com
</VirtualHost>

您的主机文件将反映您选择的网址...在这种情况下...testing.com

127.0.0.1      testing.com

【讨论】:

    【解决方案2】:

    我遇到了同样的问题。我使用了上面的解决方案,并且成功了。

    Apache rewrite_module 也必须在 wamp 中启用。

    【讨论】:

      【解决方案3】:

      如果你的 laravel 项目位于 c:\wamp\laravel\ 那么你应该可以调用 http://localhost/laravel/public 并查看默认的 laravel 欢迎页面或您自己的。

      如果是这样,你必须检查两个方面:

      1. 打开您的 /app/config/app.php 文件并检查 url 的值是否指向您的项目。 'url'=&gt;'http://localhost/laravel/
      2. 然后打开您的 .htaccess 文件并在 RewriteEngine On 行下添加 RewriteBase 规则 RewriteBase /laravel/public/

      希望对您有所帮助! :)

      【讨论】:

        【解决方案4】:

        Apache rewrite_module 也必须在 WAMP 中启用。它适用于我的 wampserver。

        【讨论】:

          【解决方案5】:

          检查 rewrite_module

          前往

          • wamp 图标
          • 阿帕奇
          • Apache 模块
          • 检查rewrite_module

          干杯,你在头痛之后又来了

          【讨论】:

          • 请不要使用Thanks或Me too等cmet的接听功能。
          【解决方案6】:

          他们唯一正确的方法是将网络服务器指向public 目录。例如,如果您已将 Laravel 安装在 C:/xampp/htdocs/ 目录中,则需要使用以下设置:

          DocumentRoot "C:/xampp/htdocs/public"
          <Directory "C:/xampp/htdocs/public">
          

          切勿在公用文件夹中编辑.htaccess。如果你这样做了,你需要取回原始文件。进行这些更改后重新启动 Apache。

          【讨论】:

            【解决方案7】:

            实际上它有一个非常简单的解决方案。您所要做的只是检查 apache 中的重写模块。检查图像中的步骤 laravel problem with wamp server solution

            【讨论】:

              【解决方案8】:

              在根目录下创建一个 index.php 文件。

              <?php
              header("refresh: 0; http://localhost/appnamehere/public");
              ?>
              

              如果您在一个域下有多个站点,您可能无法更改您的公共 webroot。

              我有所有正确的设置,正确的 .htaccess 文件在正确的位置,但它不会重定向。这为我解决了问题。

              这篇文章有助于使 wampserver/wampmanager 链接正常工作。 Project Links do not work on Wamp Server

              后记:

              如果您在虚拟主机文件中添加: E:\wamp\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf 然后创建一个指向公共目录的虚拟主机,如下所示:

              <VirtualHost *:80>
                  ServerName Blog
                  ServerAlias Blog
                  DocumentRoot E:/wamp/www/Blog/public
                  <Directory  "E:/wamp/www/Blog/public/">
                      Options +Indexes +Includes +FollowSymLinks +MultiViews
                     AllowOverride All
                      Require local
                  </Directory>
              </VirtualHost>
              #
              

              然后你添加到 C:\Windows\System32\drivers\etc\hosts

              # localhost name resolution is handled within DNS itself.
                  127.0.0.1       localhost
                  ::1             localhost
                  127.0.0.1       Blog
                  ::1             Blog
              

              你不需要我建议的 index.php 文件。如果您不创建虚拟主机,则该文件有效,两者都不需要。它是其中之一(尽管拥有它并没有什么害处)。

              【讨论】:

                猜你喜欢
                • 2015-07-04
                • 2015-06-05
                • 1970-01-01
                • 2016-01-10
                • 1970-01-01
                • 2016-06-11
                • 2019-09-22
                • 2012-11-08
                • 2013-12-23
                相关资源
                最近更新 更多