使用 laravel 5 从 url 中删除 index.php
Remove index.php from the url with laravel 5
我在这里查看了很多关于从 url 中删除 index.php 的帖子,但我无法得到想要的结果,我已经将本地 url 站点名称添加到虚拟主机文件(我使用 wamp),当我这样写 url 时,它可以工作 http://first-app.com
我的问题是当我导航到另一个文件夹时 "songs" 这个 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>
可以通过修改这个文件来解决吗?或者我需要修改位于 public 文件夹中的 .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 ^(.*)/$ / [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
我只需要在 apache 服务器中启用 rewrite_module
然后重新启动,因为我使用 wamp 我只从列表菜单中选择了模块
Here is a complete list how it can be done for Mac, Linux and Windows
我在这里查看了很多关于从 url 中删除 index.php 的帖子,但我无法得到想要的结果,我已经将本地 url 站点名称添加到虚拟主机文件(我使用 wamp),当我这样写 url 时,它可以工作 http://first-app.com
我的问题是当我导航到另一个文件夹时 "songs" 这个 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>
可以通过修改这个文件来解决吗?或者我需要修改位于 public 文件夹中的 .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 ^(.*)/$ / [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
我只需要在 apache 服务器中启用 rewrite_module
然后重新启动,因为我使用 wamp 我只从列表菜单中选择了模块
Here is a complete list how it can be done for Mac, Linux and Windows