Laravel清洁网址问题

时间:2013-10-13 19:46:50

标签: apache .htaccess laravel laravel-4 virtualhost

我知道这是一个很多人的问题,但即使在修好了所有内容之后,我仍然没有得到任何结果。

此刻我去

  

...矮子/公共/用户

我得到以下

  在这台服务器上找不到

shorty ../ public / index.php / users。

但是当我在url栏中添加index.php时就可以了。 (不干净的版本)

这是我的htaccess文件

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*) index.php/$1 [L]
</IfModule>

这是我的httpd.conf文件

<Directory "/Library/WebServer/Documents">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks MultiViews

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

2 个答案:

答案 0 :(得分:2)

尝试将RewriteRule更改为^ index.php。此外,如果失败,请分享您正在使用的域的整个虚拟主机配置,以便我可以看到您的文档根目录。

如果您的Laravel安装不在域的根目录下,则需要添加RewriteBase。例如,如果您将其安装在公共文档根目录中的文件夹中,例如//localhost/myfolder/,那么您的RewriteBase必须设置为/myfolder/public/

此外,如果您将Laravel安装在您的webroot上方而不是下方(不推荐),那么您的RewriteBase应设置为/public/

但是,就像我说的那样,相对来说,我无法分辨出你所在的域名。因此,如果以上操作不起作用,请使用完整的虚拟主机配置更新您的问题。

答案 1 :(得分:0)

我遇到了同样的问题,通过转移到Xampp服务器并将'index' => '',放在app/config/app.php内,它对我有用。希望它对你也有效。快乐的编码。