![](/img/trans.png)
[英]redirect http://www.example.com/ to https://www.example.com/ with htaccess
[英]Htaccess only home page https://a.com to https://www.a.com redirect
我的htaccess(codeigniter)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
如果訪問者打開主頁https://example.com需要重定向-> https://www.example.com
但是我已經重定向了我的鏈接。 我需要一起做當前的代碼。
我能怎么做?
編輯1:
這是我想要的:
https://example.com - > https://www.example.com , https://example.com/somepage - > https://example.com/somepage (無變化), https://開頭WWW。 example.com/otherpage.html- > https://example.com/otherpage.html (不使用www重定向)
只有主頁將使用www。 標簽
所有其他頁面均不使用www。
嘗試這個
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
您應該使用RedirectMatch
實現目標。
嘗試這個:
RedirectMatch 301 https://example.com https://www.example.com
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.