Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Helicon ISAPI Rewrite 3 - Add www preserve query string

Posted on 2010-08-18
4
Medium Priority
?
1,640 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
[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 30

Accepted Solution

by:
Brad Howe earned 2000 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

721 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