I have recently moved my website to a new domain.

The previous domain had SSL installed and it was https://example.com. My new domain is http://newexample.com and It doesn't have SSL on it. I used google webmaster tools to change the address of my website but it can't verify 301 redirect.

How can I 301 redirect https://example.com to http://newexample.com using .htaccess?

  • Don't you want to send https://example.com/ to http://newexample.com/? – ceejayoz Jul 28 '15 at 19:19
  • yeah the editor made a mistake I edited it again ! – rko4all123 Jul 28 '15 at 19:27
  • I was the editor, and I didn't make a mistake, I just fixed your formatting a bit. serverfault.com/posts/709162/revisions Thank you for clarifying though. – ceejayoz Jul 28 '15 at 19:28
  • sry then the problem was on my side . now it's ok . Please answer the question – rko4all123 Jul 28 '15 at 19:30

This should do it:

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule (.*) http://newexample.com%{REQUEST_URI} [R=301,L]
  • where is https in this line ? RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC] – rko4all123 Jul 28 '15 at 19:36
  • @rko4all123 The HTTPS requirement is the line above that. There are two conditions here - HTTPS must be on, and the hostname must be example.com, for the redirect to occur. – ceejayoz Jul 28 '15 at 19:37
  • thanks ! it works ! now I can change my address in google webmaster tools . you are awesome . – rko4all123 Jul 28 '15 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.