Redirect From HTTPS To HTTP Using PHP

17th April 2009

If you have a site with parts of it using SSL, but want to turn it off for mundane pages like the blog section then use the following code. This uses the $_SERVER['HTTPS'] variable to see if HTTPS is turned on, if it is then a header is issued and the page redirected.

Using .htaccess To Redirect HTTPS To HTTP

9th April 2009

To redirect from HTTPS to HTTP on the home page only using the following rule.

  1. RewriteCond %{HTTPS} on
  2. RewriteRule ^/?$ http://%{SERVER_NAME}/ [R=301,L]

The variable %{HTTPS} will be either "on" or "off" and will be enabled even if SSL is not installed on your site. The rule above sees that HTTPS is on and redirects the home page to the HTTP version. You can even chain lots of rules together like this.

JavaScript Redirects

11th March 2009

There are two main ways in which to redirect the browser using JavaScript, both of which look at the location of the window object. These are the location.href property and location.replace function.


The following example will cause the page to redirect to another page, keeping the browser history. This might seem like a minor point, but if you redirect a user to another page they will be able to click back, which will mean that they are redirected again.

Using Redirection Inside a Plugin In Zend Framework

2nd February 2009

I had a situation the other day where I had an application in Zend Framework and I wanted to redirect a user to another page. This is fine if you are inside a controller as you can use the _redirect() controller helper, but in this instance I was running the code from inside a plugin and so therefore didn't have direct access to the controller.

Redirect One Directory To Another With .htaccess

To stop access to a directory (and anything in that directory) all you need is a simple RewriteRule.

philipnorton42 Mon, 05/19/2008 - 08:55

Avoiding URL Canonicalisation With mod_rewrite And Apache

22nd February 2008

URL canonicalisation is where you have a website with different URLs outputting the same content. When search engine spiders see all this content that is the same they can get confused as to what page to display in search engine result pages. The following URLs, although they are different, actually produce the same content.

Redirecting The Page In PHP

13th January 2008

To redirect the current page to a different location you use the header() function in the following way: