简体   繁体   中英

Redirect https and http in .htaccess

I have an old url ( test.me.com ) and I would like to redirect it to www.me.com .

So I added this line to my .htaccess file:

RewriteRule ^(.*)$ http://www\.me\.com/$1 [L,R=301]

But as it turns out, Google has already indexed some of the pages. And since I have an SSL Certificate, the full url is https://test.me.com . So the redirect of above won't affect the https files...

I've tried this one, but with no luck.

RewriteCond %{HTTPS} =on
RewriteRule ^(.+)$ - [env=ps:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.+)$ - [env=ps:http]

# redirect urls with index.html to folder
RewriteCond %{HTTP_HOST} ^test.me.com [NC]
RewriteRule ^.*$ %{ENV:ps}://www.me.com/%1 [R=302,L]

How can I configure my .htaccess file that both http://test.me.com and https://www.test.com are redirected to http://www.me.com ?

# redirect https requests or request on test.me.com to http://www.me.com
RewriteCond %{HTTPS} =on [OR]
RewriteCond %{HTTP_HOST} ^test\.me\.com$ [NC]
RewriteRule ^(.*)$ http://www.me.com/$1 [R=301,L]

or alternatively to also redirect me.com to www.me.com

RewriteCond %{HTTPS} =on [OR]
RewriteCond %{HTTP_HOST} !^www\.me\.com$ [NC]
RewriteRule ^(.*)$ http://www.me.com/$1 [R=301,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM