【问题标题】:Remove index.php from the url with laravel 5使用 laravel 5 从 url 中删除 index.php
【发布时间】:2015-10-09 20:00:49
【问题描述】:

我在这里查看了许多关于从 url 中删除 index.php 的帖子,但我无法获得所需的结果,我已经将我的本地 url 站点名称添加到虚拟主机文件(我使用 wamp)并且当我像这样编写 url 时它可以工作http://first-app.com

当我导航到“歌曲”之类的另一个文件夹时,我的问题是这个 url 不起作用,我得到 url not found

http://first-app.com/songs

如果我使用 index.php 它可以工作

http://first-app.com/index.php/songs

这是我的 httpd-vhosts.conf 文件:

<Directory C:\wamp\www\composer-demo\first-app\public>
Order Deny,Allow 
Allow from all
</Directory>

<VirtualHost *:80>
DocumentRoot "C:\wamp\www\composer-demo\first-app\public"
ServerName first-app.com
</VirtualHost>

可以通过修改这个文件来解决吗?或者我需要修改位于公共文件夹中的 .htaccess 文件?在这里:

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

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

【问题讨论】:

  • 这是一个 cms 或其他软件驱动的测试站点吗?如果是这样的话,它看起来有一套不完整的重写规则。每种类型对如何构建重写规则都有不同的要求,因此如果没有更多信息,就无法真正猜到。
  • stackoverflow.com/questions/21527573/… 显然 laravel 不使用 apache rewrite 通过查询字符串或其他方式获取其 url 数据,因此我无法提供任何建议。确保在寻求帮助时发布类似的相关信息,这实际上根本不是重写问题,而是 Laravel 问题。
  • @Lizardx 很明显我说的是 Laravel,你看到标题和标签了吗???

标签: php apache laravel


【解决方案1】:

我只需要在 apache 服务器中启用rewrite_module 然后重新启动,因为我使用 wamp 我只从列表菜单中选择了模块

Here is a complete list how it can be done for Mac, Linux and Windows

【讨论】:

    猜你喜欢
    • 2015-10-11
    • 2017-01-28
    • 2018-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-16
    • 2017-09-28
    • 2014-05-15
    相关资源
    最近更新 更多