所以我大学的网站管理员说他们分配给我的服务器空间不支持 htaccess 重写规则。但根据我对 Laravel 的理解,.htaccess 必须启用。有什么解决办法吗?
我的 .htaccess 代码是这样的
<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]
RewriteBase /
RewriteRule ^.+/experiment/(.*)$ /experiment/$1 [L,NC,R]
</IfModule>
最佳答案
不,不能。 Laravel 使用唯一的 .php
文件,即 index.php
,如果您删除 .htaccess
,您将无法使用某些Laravel 功能(例如路由)。
经过一些修改后,您将能够使其工作,但最终,您将得到丑陋的 URL,例如 /index.php/hello-page
和一些硬 -修复错误。
这里唯一好的选择是购买一些便宜的虚拟主机。
关于apache - Laravel 5.1 应用程序可以在没有 .htaccess 重写的情况下运行吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35924798/