Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

rewrite for subdomain to SSL?

Posted on 2006-11-03
4
Medium Priority
?
854 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
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 1000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month11 days, 17 hours left to enroll

916 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