Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are using CISCO hardware load balancer for enforcing SSL(https). Now i need to force some url always to http and all other url to https.

for ex encrypt_no_need.php always need to be http i.e if user try to load with this need to forced to load as

and all other pages directly opposite to this..(all the time on https)

How to do this? and where to control this ?

share|improve this question

you can do this two ways. have the loadbalancer direct https requests to a different port or insert a header into the request specifying that https has been used. (this may already be in place) Then you need to modify your enforcment script to check the port or header instead of whether the request came over https and redirect to an http or https url as appropriate.

share|improve this answer
Redirecting to different port? you mean to https port of Apache. i think that needs ssl certificate configuration for that apache webserver. but here we are installed that in load balancer. Second approach is looks but how to read the headers in php i have tried to list all the headers in php using apache_request_headers() but that didnt list anything like X-FORWARD-PROTO or X-FORWARD-FOR !! can you tell me how to check the header values? – gnanz Apr 21 '11 at 11:27
Where to write the enforcement script? in laod balancer? apache? Can you provide any sample script – gnanz Apr 21 '11 at 12:08
i'm not familiar with your specific load balancer, but on there you can set which servers/ports you are load balancing between for each protocol and choose to insert X-Forwarded-Proto. This should then appear in apache_request_headers. – JamesRyan Apr 21 '11 at 15:10
your script should basically be at the top of the php page. Check to see if you are in https and if so redirect to the same url with http instead. You might want to wrap it up into a function that you caan easily include whenever you want to force a page to http or https – JamesRyan Apr 21 '11 at 15:15

you can as well use rewrites at your vhost level for the specific file. Try checking the mod_rewrite of apache for more details.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.