Hi all I want to redirect my primary domain to https (http:// www. website.com to https:// www. website.com) and exclude all sub domains. (http:// xyz. website.com to remain as http:// xyz. website.com) I have been on google for too long and couldnt find the right solution, please help My .htaccess file RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https:// %{HTTP_HOST}%{REQUEST_URI} [R,L] - Slax
RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} www.mydomain.com RewriteRule (.*) https://www.mydomain.com/$1 [R=301,L] Code (ApacheConf): I think the rule could be just RewriteRule (.*) https://www.mydomain.com$1 [R=301,L] Code (markup): leaving out the extra slash, which should be included in the rule match. But I always forget whether that works or not.
What is wrong with your current .htaccess? Seems like it should do the job Additionally, you should exclude robots.txt file from this rule, to make it accessible for Search Engines like this RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} !/robots.txt RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} PHP: