I have two websites example1.com and example2.com hosting in same server.
example1.com is https secure and should redirect to https://www.example1.com
example2.com is not secure it should redirect to http://www.example2.com
Currently I am using
# ensure www.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# ensure https
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
But it is redirecting both URLs.
Please help how to write different RewriteRule for both URLs in single .htacess file.

Madan ShekarRank #428 · 5.9K reputationPosted Jan 2, 2019, 12:02 AM EST
Ravishankar NRank #241 · 10.2K reputationPosted Feb 25, 2019, 3:22 AM EST
Add the below apache rewrite rules should do the trick for you.
The above rules will do a 301 redirect of:
Vivek KumarRank #272 · 9.3K reputationPosted Feb 28, 2019, 8:07 AM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts