Keep Server Online
  
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
  
or
  
 
  
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
  
Thank You! Steffen
  
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
 |    |   
 | 
     Topic: Redirect primary domain http to https but exclude subdomains | 
 |   
| Author | 
  | 
 
slax
 
 
  Joined: 09 Sep 2015 Posts: 1
 
  | 
 Posted: Wed 09 Sep '15 14:05    Post subject: Redirect primary domain http to https but exclude subdomains | 
     | 
 
  | 
 
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
 
 	  | Code: | 	 		  
 
RewriteEngine On
 
RewriteCond %{HTTPS} off
 
RewriteRule (.*) https:// %{HTTP_HOST}%{REQUEST_URI} [R,L]
 
 | 	  
 
- Slax | 
 
  | 
 
| Back to top | 
 | 
 
James Blond Moderator
  
  Joined: 19 Jan 2006 Posts: 7442 Location: EU, Germany, Next to Hamburg
  | 
 Posted: Thu 10 Sep '15 9:33    Post subject:  | 
     | 
 
  | 
 
In your vhost
 
 
 	  | Code: | 	 		  
 
RewriteEngine On
 
RewriteBase /
 
 
#not redirect for for 404
 
RewriteCond %{REQUEST_FILENAME} !-f
 
RewriteCond %{REQUEST_FILENAME} !-d
 
RewriteRule (.*) - [L]
 
 
RewriteCond %{HTTPS} !=on
 
RewriteCond %{REQUEST_URI} !^/404\.html
 
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
 
 | 	 
  | 
 
  | 
 
| Back to top | 
 | 
 
 
 
 
 | 
 
 
 |  
 
 |  
  |   
 |