2015-06-05 49 views
0

我正在使用laravel,我有一個問題將客戶重定向到httpswww。 例如:CloudFlare SSL(htaccess)重定向到laravel上的index.php

來自:http://domain.com/abc/def

到:https://www.domain.com/abc/def

這是我.htaccess代碼:

RewriteCond %{HTTP:X-Forwarded-Proto} !https 

# First rewrite to HTTPS:A 
# Don't put www. here. If it is already there it will be included, if not 
# the subsequent rule will catch it. 
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

# Now, rewrite any request to the wrong domain to use www. 
RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

它已經重定向到https://www.但它總是重定向到index.php文件。

例如,而不是重定向到https://www.domain.com/abc它重定向到https://www.domain.com/index.php

回答

0

好,我固定它。我只是需要之前laravel的代碼把這個代碼:

# Redirect Trailing Slashes... 
RewriteRule ^(.*)/$ /$1 [L,R=301] 

# Handle Front Controller... 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule^index.php [L] 

所以現在全htaccess的是:

<IfModule mod_rewrite.c> 
<IfModule mod_negotiation.c> 
    Options -MultiViews 
</IfModule> 

RewriteEngine On 

RewriteCond %{HTTP:X-Forwarded-Proto} !https 
# First rewrite to HTTPS:A 
# Don't put www. here. If it is already there it will be included, if not 
# the subsequent rule will catch it. 
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
# Now, rewrite any request to the wrong domain to use www. 
RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

# Redirect Trailing Slashes... 
RewriteRule ^(.*)/$ /$1 [L,R=301] 

# Handle Front Controller... 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule^index.php [L] 

相關問題