【发布时间】:2014-04-12 00:43:50
【问题描述】:
目前,我只能访问我的 Laravel 项目中的链接,如果它们是 domain.com/index.php/somepage 的形式。我希望能够使用domain.com/somepage 之类的 URL 进行访问。在我的本地 Windows 机器上,它工作正常。我的服务器在 Ubuntu 上并运行 Apache 2.4.6,rewrite 模块是通过a2enmod rewrite 启用的。我的 .htaccess 是 Laravel 附带的默认值:
<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>
我还尝试了 Laravel 文档中的替代方法,无论是否使用 <IfModule>:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
我意识到以前有人问过这个问题,但我似乎仍然可以将它与我见过的其他示例一起使用。我猜它一定是我没有设置的一些 Apache 配置。
【问题讨论】:
-
你没有说出你想要什么而面临麻烦?
-
@SheikhHeera 谢谢,我把它加进去了。这个问题已经得到了回答。
标签: apache .htaccess mod-rewrite ubuntu laravel