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

I'm looking to have a certain page, example.php, redirect to the non-SSL version if it is accessed via SSL. What type of rewrites should I be looking at?

share|improve this question

The following code may be used...

server {
  listen 443 ssl;

  ssl_certificate /path/to/cert.crt;
  ssl_certificate_key /path/to/cert.key;

  location = /path/to/example.php {
    return 301 http://$host$request_uri;

  # other directives here

server {
  listen 80;

  location = /path/to/example.php {
    # include directives to process PHP here

  # return all other requests to SSL
  location / {
    return 301 https://$host$request_uri;
share|improve this answer
I have my SSL and non-SSL server block in one block. – Artie Aug 23 '13 at 23:45
Is it hard to split / divide it? – Pothi Aug 24 '13 at 3:25

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.