Solved

rewrite for subdomain to SSL?

Posted on 2006-11-03
4
845 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
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 …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 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