Isuru Udana Senarath
Isuru Udana Senarath

Reputation: 59

redirect page(https) to external URL(http) with htaccess

I want to redirect https://www.siteone.com/testpage-es.html to http://newsite.com

When I'm testing my code in a htaccess tester (https://htaccess.madewithlove.be/) it shows the following result. "The new URL is http://newsite.com:443/"

My code is snippet as follows.

RewriteCond %{HTTP_HOST} ^www.siteone.com$ [NC]
RewriteRule ^testpage-es.html$ http://newsite.com [L,R=301,NC]

Could anyone please help me to get rid of ":443/" part?

Upvotes: 0

Views: 117

Answers (2)

Isuru Udana Senarath
Isuru Udana Senarath

Reputation: 59

Finally, I was able to find the answer. This is only a problem related to the htaccess checker with https websites. The code I mentioned above worked properly in the live environment. (I was hesitant to check it with the live web site without being 100% sure. However, it works well in the live environment.)

Upvotes: 0

user10946716
user10946716

Reputation:

Add port to your rewrite

RewriteCond %{HTTP_HOST} ^(www\.)?siteone\.com$ [NC]
RewriteRule ^testpage-es\.html$ http://newsite.com:443 [L,R=301,NC]

But port 443 is default for SSL/HTTPS so rule should look (with https:// not port number)

RewriteCond %{HTTP_HOST} ^(www\.)?siteone\.com$ [NC]
RewriteRule ^testpage-es\.html$ https://newsite.com [L,R=301,NC]

Upvotes: 1

Related Questions