我正在嘗試重定向到
https://example.com來自https://www.example.com、http://example.com、http://www.example.com
- - - - - - - - - 和 - - - - - - - - -
https://example.com/sub_page/pages來自 https://www.example.com/sub_page/pages , http://example.com/sub_page/pages , http://www.example.com/sub_page/頁面
在 .htaccess 上,但我的 sub_pages 沒有正確重定向。可能是因為下面的代碼沖突。我在互聯網上閱讀了很多文章,但沒有發現有用。
我的 .htaccess 檔案
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example.com$
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
我想你明白了我的全部觀點。簡而言之,我想將所有請求重定向 到 non=www 和 https。請在這件事上給予我幫助,
uj5u.com熱心網友回復:
這可能是您正在尋找的:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]
這應該在實際的 http 服務器配置中起作用,或者,如果您無權訪問它,則在位于 http 主機檔案根目錄中的分布式組態檔 (".htaccess) 中起作用。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/477061.html
