Laravel 访问 [英] Laravel htaccess

查看:30
本文介绍了Laravel 访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在本地安装了新的 Laravel.htaccess 或 Apache 设置似乎存在问题.我已经研究了几个小时并尝试了我阅读的所有内容.

I've setup a new install of Laravel on my local. It appears there are issues with htaccess or Apache settings. I've researched for a number of hours and tried everything I read.

  • OSX 狮子 10.7.5
  • MAMP 3.0.5
  • PHP 5.5.10
  • 正在加载 mod_rewrite.

我的开发服务器与其他站点一起工作.这是我第一次尝试 Laravel 4.

My development server works with other sites. This is the first time I am trying Laravel 4.

我在位于 website.dev:8888/的欢迎页面上收到 403 Forbidden

I get a 403 Forbidden on the welcome page which is located at website.dev:8888/

Apache 给了我这个错误:选项指令禁止目录索引

Apache gives me this error: Directory index forbidden by Options directive

这是我的 .htaccess 文件内容:

Here is my .htaccess file content:

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

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

以下是我采取的一些额外措施:

Here are a few additional actions I've taken:

  • AllowOverride 在 httpd.conf 中设置为 All
  • 在 httpd-vhosts.conf 中添加了虚拟主机代码部分
  • 验证主机文件包含站点 127.0.0.1 website.dev 的一行

我还尝试了在文章中找到的 htaccess 中的各种行,并且每次更改 conf 文件时我也重新启动了 apache.没有路线工作.当我访问 website.dev:8888/public 时,我得到一个空白页面,没有错误.如果我转到我创建的路由,例如 website.dev:8888/users,我会收到 404 not found 错误.

I've also tried various lines in the htaccess which I found in articles and I also restarted apache each time I made changes to the conf files. No routes work. When I go to website.dev:8888/public I get a blank page, no error. If I go to a route I created such as website.dev:8888/users I get a 404 not found error.

感谢您的帮助!

推荐答案

这个解决方案运行良好,对我来说是最好的解决方案.将此代码粘贴到 root htaccess 中.就这样.保持所有其他文件不变

This solution worked fine, best solution ever for me. Paste this code into root htaccess. That's all. Leave all other files as they are

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

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]

RewriteCond %{REQUEST_URI} (.w+$) [NC]
RewriteRule ^(.*)$ public/$1

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
</IfModule>

这篇关于Laravel 访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆