Solved

rewrite for subdomain to SSL?

Posted on 2006-11-03
4
848 Views
Last Modified: 2011-09-20
Hello,

I’m looking to enforce SSL access to a subdomain using a rewrite rule.  When users visit http://subdomain.domain.com/* the rewrite rule should point the user at httpS://subdomain.domain.com/*

I’ve looked at the following rule, which works across the whole site, but I’m not familiar with the syntax to modify it for a subdomain only.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Any help appreciated,
/wl
0
Comment
Question by:windylad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 43

Expert Comment

by:ravenpl
ID: 17865796
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain.domain.com
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
0
 
LVL 43

Accepted Solution

by:
ravenpl earned 250 total points
ID: 17865806
Oh, the last rule should look like [last, redirect externally]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
0
 

Author Comment

by:windylad
ID: 17866317
Hi ravenpl,

Thanks for the answer.  I've tried both of the following and both work; whats the difference in the last line?

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain.domain.com
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain.domain.com
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R]

Thanks,
/wl
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 17866370
L - means don't try next rewriteRules on this result
R - means don't rewrite, but redirect(301 response code is sent to client) - I guess it's default if protocols/ports do not match...
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question