你好,我正在使用以下htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
因为做了laravel路由。
当我浏览示例localdevurl/public/users时,我得到以下错误(404)
未找到
在此服务器上找不到请求的URL/Users/用户名/Sites/sitefolder/public/index.php/user。
但正如您所看到的,它在错误中显示了index.php。当我把index.php放在我的url中时,它确实有效。我已经打开了我的apache配置中的所有内容。
httpd.conf
有人看到我在这里做错了什么吗?
在.htaccess文件中,您在index.php部分之后传递请求,而不是允许laravel路由系统处理它,这是:
RewriteRule ^(.*)$ index.php/$1 [L]
应为原始.htaccess
RewriteRule ^ index.php [L]
我在index.php部分也遇到了同样的问题,这就是我解决的方法:当您启用userdir模块时,会出现一个问题,这似乎是基于错误消息的URL的情况。
可能的解决方案:
- 在webserver文件夹中创建一个指向用户web目录的公共laravel项目文件夹的符号链接。例如:
# ln -s ~/public_html/mylaravel4/site/public/ /var/www/mycoolsite
然后您可以访问http://localhost/mycoolsite
- 将RewriteCond和RewriteRule行替换为:
FallbackResource /index.php
确保为特定vhost将AllowOverride设置为All而不是None,并在httpd.conf中设置Order allow,deny而不是Order deny,allow。
AllowOverride all
Order allow, deny