Solved

rewrite for subdomain to SSL?

Posted on 2006-11-03
4
835 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
  • 3
4 Comments
 
LVL 43

Expert Comment

by:ravenpl
Comment Utility
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
Comment Utility
Oh, the last rule should look like [last, redirect externally]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
0
 

Author Comment

by:windylad
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now