我的Laravel路线只能通过index.php
问题描述:
可见我已经检查确保我已启用mod_rewrite重新启动我的网络服务器。我的.htaccess似乎很好。我错过了什么?我的Laravel路线只能通过index.php
<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 ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule^index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
我的虚拟主机如下:
<VirtualHost *:80>
ServerName cms.dev
ServerAdmin [email protected]
DocumentRoot /var/www/html/cms/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
答
你已经创建了一个.htaccess文件,但实际上并没有告诉你的虚拟主机“允许”的.htaccess覆盖配置。换句话说,你还没有启用htaccess suppport。将以下内容添加到您的VirtualHost块以启用它:
<Directory "/var/www">
AllowOverride All
</Directory>
根据您的要求更改目录路径。
你达人!这工作。 –
我很高兴它有帮助。 :) –