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
Solved

Helicon ISAPI Rewrite 3 - Add www preserve query string

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

828 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