Solved

Rewrite to HTTPS URL

Posted on 2013-12-28
3
189 Views
Last Modified: 2014-10-22
Hello All,

On the webserver I need to create a rewrite rule. Please suggest how I can use the RewriteCond to create a if then else logic, such that,

 if I receive a URL with request parameter (showNavigation=y)
  then
     RewriteRule to use the https url,
Else if the request parameter (showNavigation=n)
then
  RewriteRule to use the http url.


I need your expert advice on below RewriteRule . Please suggest how I can add the RewriteCond to check for the showNavigation value.

RewriteRule ^showNavigation=y$ https://hostname/webapp/wcs/stores/servlet/JobListingsHandler?storeId=10051&catalogId=10001&showNavigation=y&langId=-3  [NC,L,R]

RewriteRule ^showNavigation=n$ http://hostname/webapp/wcs/stores/servlet/JobListingsHandler?storeId=10051&catalogId=10001&showNavigation=n&langId=-3  [NC,L,R]

Thanks
0
Comment
Question by:qutbud
[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 Comments
 
LVL 51

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 39745236
The query string is not testable from RewriteRule.  You need to use RewriteCond instead:
RewriteCond %{QUERY_STRING} showNavigation=y [NC]
RewriteRule /?(.*)$ https://mydomain.com/$1 [QSA,NC,R,L]

Open in new window

While you're at it, you should probably test if HTTPS is already lit up.  See here for more information: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond
0

Featured Post

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This video teaches users how to migrate an existing Wordpress website to a new domain.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

636 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