Solved

Rewrite to HTTPS URL

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now