2016-12-26 63 views
0

我想重定向每個可能的url組合到單個路徑。http到https重定向到所有posibilties到一個url

例如,

HTTP:/example.com --->的https:/example.com/abc/cde

的https:/example.com - > HTTPS:/example.com/abc/cde

http:/example.com/abc/cde-> https:/example.com/abc/cde

我可以通過以下mod_rewrite設置來處理1和3個案例,但無法執行2個重定向有一個幫助。

爲了避免鏈接轉換,我有一個/在網站的例子。

RewriteEngine敘述在

的RewriteCond%{HTTPS}關閉

的RewriteCond%!{HTTP:X-轉發 - 協議} HTTPS

重寫規則^(。*)$○一二三二七九五四三三四○一六九七一五三二一○{HTTP_HOST}%{ REQUEST_URI} [R = 301,L]

回答

0

應該使用[OR]重寫標誌

RewriteEngine On 
RewriteCond %{HTTPS} off [OR] 
RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]