开发者

htaccess rewrite for https

开发者 https://www.devze.com 2023-02-19 20:46 出处:网络
Given this rule (that strips www from urls for http): < IfModule mod_rewrite.c > RewriteCond %{HTTPS} !=on

Given this rule (that strips www from urls for http):

< IfModule mod_rewrite.c >
   RewriteCond %{HTTPS} !=on
   RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
   RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</ IfModule >

how do I configure the rewrite to work for 开发者_运维问答https as well?


A simple search found this:

# remove www from host
RewriteCond %{HTTP_HOST} ^www\.(.+)
RewriteCond %{HTTPS}s/%1 ^(on(s)|offs)/(.+)
RewriteRule ^ http%2://%3%{REQUEST_URI} [L,R=301]

Note: the [L] directive may be redundant in your case if it's not the [L]ast rule applied...

0

精彩评论

暂无评论...
验证码 换一张
取 消