How to write a simple php redirect script
If your looking to redirect users to a different page on your site or need to put together an affiliate link then you’ll be happy to know that you can easily achieve this using php, its not complex and it works in all browsers. The code is as follows.
<?php
header( ‘Location: http://www.yourdomain.com/new_page.html’) ;
?>
Simply change the http://www.yourdomain.com/new_page.html with your url or affiliate link. The only thing to watch however is not to send any html to the browser before the script block otherwise it won’t work. So for example, if you used something like this in your page it would fail.
<html>
<head>
<?php
header( ‘Location: http://www.yoursite.com/new_page.html’ ) ;
?>
</head>
<html>
To be on the safe side I create a completely blank php page and simply add the php script block and nothing else. If you want to check that your redirect script is working then the best way is to use this headers tool from SEO Consultants. Enjoy!
No Comments
No comments yet.
Comments RSS Feed TrackBack URL
Sorry, the comment form is closed at this time.












