logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

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.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Redirect primary domain http to https but exclude subdomains
Author
slax



Joined: 09 Sep 2015
Posts: 1

PostPosted: Wed 09 Sep '15 14:05    Post subject: Redirect primary domain http to https but exclude subdomains Reply with quote

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: 7373
Location: Germany, Next to Hamburg

PostPosted: Thu 10 Sep '15 9:33    Post subject: Reply with quote

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


Reply to topic   Topic: Redirect primary domain http to https but exclude subdomains View previous topic :: View next topic
Post new topic   Forum Index -> Apache