Solved

Rewrite to HTTPS URL

Posted on 2013-12-28
3
185 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to dynamically set the form action using jQuery.

685 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