PHP Redirect

February 7, 2012 6:21 pm Published by Leave your thoughts

PHP Redirect to Self (refresh)

Header('Location: '.$_SERVER['PHP_SELF']);
Exit(); // if more than one header, you will get "header already sent" error if don't exit out

PHP Redirect to other page

header( 'Location: http://www.example.com/other_page.html' ) ;

Why you should avoid using javascript redirect?

A : Due to Google’s redirect penalty.

https://www.sitepoint.com/community/t/google-found-my-javascript-redirect/64157/9

Update on Google penalty (04/17/16): https://searchenginewatch.com/sew/news/2342766/google-warns-against-sneaky-redirects-in-updated-guidelines

Tags: , , ,

Categorized in:

This post was written by hackya