2015-11-05 88 views
0

我需要重定向所有種類的頁面打開像http://oursite.comhttp://www.oursite.comhttpS://WWW.oursite.com的Apache2 - 的.htaccess所有重定向到https:// WWW

你能給我那種規則的htaccess的規則?

<IfModule mod_rewrite.c> 
ErrorDocument 404 /page-404.php 
RewriteEngine On 

     RewriteCond %{REQUEST_FILENAME} -f [OR] 
     RewriteCond %{REQUEST_FILENAME} -d 
     RewriteRule .+ - [L] 

RewriteCond %{THE_REQUEST} ^[A-Z]+\s([^\s]+)\.php\s [NC] 
RewriteRule .* %1.html [R=301,L] 

# make sure .php file exists for the requested .html file 
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC] 
RewriteRule ^(.+?)\.html$ $1.php [L,NC] 
</IfModule> 

在此先感謝!

+0

任何你試過,包括閱讀文檔和/或聯機幫助? – planetmaker

+0

它在那裏.... –

回答

0

短而簡單:

<ifmodule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{HTTPS} off 
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
</ifmodule> 
相關問題