Solved

Helicon ISAPI Rewrite 3 - Add www preserve query string

Posted on 2010-08-18
4
1,586 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

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 it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

12 Experts available now in Live!

Get 1:1 Help Now