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

x
?
Solved

Rewrite to HTTPS URL

Posted on 2013-12-28
3
Medium Priority
?
190 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Suggested Courses

670 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