Solved

Helicon ISAPI Rewrite 3 - Add www preserve query string

Posted on 2010-08-18
4
1,597 Views
Last Modified: 2012-05-10
I'm trying to write a rule to do 3 things.

Add a www subdomain if it's missing and preserve the https if specified while preserving the query string parameters.

So:

mydomain.com?page=1   should become   http://www.mydomain.com?page=1
http://mydomain.com?page=1     should become   http://www.mydomain.com?page=1
https://mydomain.com?page=1    should become    https://mydomain.com?page=1
http://mydomain.com/search?page=1     should become   http://www.mydomain.com/search?page=1
https://mydomain.com/search?page=1    should become   https://mydomain.com/search?page=1


Any code for this would be greatly appreciated.

0
Comment
Question by:collages
  • 3
4 Comments
 
LVL 30

Accepted Solution

by:
Brad Howe earned 500 total points
ID: 33470788
Hi there,
Take a look here. (http://www.helicontech.com/isapi_rewrite/doc/examples.htm)
Redirecting non-www version to www
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
Force to SSL or non-SSL for certain locations
#Redirect non-HTTPS to HTTPS
RewriteCond %{HTTP:Host} (.*)
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (.*)
RewriteRule .? https://%1%2 [R,L]
Cheers,
Hades666
0
 
LVL 1

Author Comment

by:collages
ID: 33501273
using:

RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]

mydomain.com is redirecting to https://www./
0
 
LVL 1

Author Comment

by:collages
ID: 33501313
Ah, I see.  Missing the line at the beginning.

RewriteCond %{HTTPS} (on)?


So it worked with:



RewriteEngine on

#Redirecting non-www version to www
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
0
 
LVL 1

Author Closing Comment

by:collages
ID: 33502541
with the addition of

RewriteCond %{HTTPS} (on)?


which was included in the URL provided (which is why it's a complete solution)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Debug Tools to analyse IIS process: This article focus on taking memory dumps from IIS to determine which code is taking more time and to analyse which calls hangs/causes more CPU usage. To take dumps,download the following. Install1: To st…
Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
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 …

947 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

23 Experts available now in Live!

Get 1:1 Help Now