【发布时间】:2015-10-28 00:43:42
【问题描述】:
我最近在 LAMP 服务器下安装了 laravel,但如果我没有在 url 中为 index.php 以外的其他路由指定 public,它就无法工作。
这是我的 apache 站点配置 (/etc/apache2/sites-available/furbook.com.conf):
<VirtualHost *:80>
ServerName furbook.calhost.com
DocumentRoot "/var/www/html/furbook.com/public"
<Directory "/var/www/html/furbook.com/public">
AllowOverride all
</Directory>
</VirtualHost>
然后从/etc/apache2/sites-enabled创建了一个符号链接:
sudo ln -s ../sites-available/furbook.com.conf
最后,这是我在furbook/public 中的.htaccess 文件:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
现在我可以跳过public 文件夹,localhost/furbook.com 按预期重定向到public/index.php。
但问题是当我尝试路由像 localhost/furbook.com/cats 这样的 url 时,它会抛出一个找不到页面的错误。
如果我使用localhost/furbook.com/public/cats然后按预期工作。
我错过了什么?
【问题讨论】:
标签: php apache .htaccess laravel