Php Redirect Snippets

24 October, 2016   

You should NOT use this if you are ACTUALLY using WordPress.

26 February, 2011   

This redirects visitors to a new URL using a 301 redirect. Using a 301 redirect is the safest way to let search engines like Google, Yahoo!, Live and Ask know your address has changed.

You should use err_headers_out() and not headers_out() when you want to send cookies in the REDIRECT response.

16 June, 2012   

You can use JavaScript window.location to redirect a visitor to a required page. You may have seen this feature used by sites with full page ads, or to redirect visitors to the site's new domain name. You can add also a timer to the script that will allow the page to redirect and the visitors will not need to click a link or type in the new URL.

30 April, 2011   

This allows you to redirect the page using meta tag. Setting content to 0 for immediate redirect.

08 June, 2011   

Did you know that search engine crawlers think that '' and '' are two different websites!? We need to help the crawlers out and tell them that the two URLs are the same. We can do this with a 301 (moved permanently) redirect. The code below will redirect requests for '' to ' .

PHP code example for redirecting from old URL to new URL

11 May, 2013   

ASP code example using a 301 redirect

15 September, 2012   

This script shows how to redirect to a specific site.

The JavaScript is just a function called redirect, and is requesting that a variable be passed to it.

29 December, 2011   

ASP code example to redirect the user to a different URL.

20 March, 2013   

ASP code example for Moved Permanently 301 Redirect

As an example, here we are redirecting to

16 February, 2012   

ASP code to ban user based on their IP address

06 June, 2012   

This function highlight_string() outputs or returns a syntax highlighted version of the given PHP code using the colors defined in the built-in syntax highlighter for PHP.

06 May, 2013   

Code example for Month Day Year Dropdown

27 October, 2011   

An example to include another PHP file into a PHP script

29 October, 2011   

Here shown an example how to Compress CSS with PHP

27 May, 2013   

Example shows here how to compress CSS with PHP

If you're looking for a great way to enable your visitors to navigate your web site, this JavaScript drop down box with automatic redirect may be what you're looking for. This JavaScript code will enable your visitors to click on a drop down box to select the location on your web site in which they would like to navigate. Once they make their...