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

Rewrite to HTTPS URL

Posted on 2013-12-28
3
183 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
3 Comments
 
LVL 50

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

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

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

Suggested Solutions

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
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?
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

829 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