我曾在我的.htaccess文件中尝试过bellow代码
<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]
#Force www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
</IfModule>
问题在于,当我点击example.com
时,它会将我重定向到www.example.com
但是当我点击example.com/ppl2016
时,它会将我重定向到www.example.co./index.php
我对此http://stackoverflow.com/questions/26549482/how-can-redirect-domain-non-www-to-www-in-laravel-4
进行了审核,但它无法帮助我。