php statement to redirect browser based on page id

BCrawler
BCrawler used Ask the Experts™
on
I would like to include an if statement to my header file and instruct it to redirect to another url if the requested page id is xy.

Reason is, as I have it currently, the browser first loads the header and certain stock content before being redirected. I dont want the browser to even load those.

Is there any way to do that with php and if so, can some one give me an example?

here is the site --wwwsattaluri.com/amazon

I have the site linked to a wordpress blog from the menu. If you click blog on menu....But it loades graphics first. I have access to the header file. So, I was thinking of using a check to see if the current page being loaded is particular and if so, redirect.

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
hi,

did u try this one header()

if($id ='xy')
{
$uri = "www.yahoo.com";
  header("Location:$URI");exit;

}
Commented:
You can do it by using .htaccess file and mod_rewrite (if you are using Apache as the web server).
You must place the .htacces file in the enter point directory of your site (often this is the root directory on the site), then place such string in the .htaccess file:
"redirect 301 /old-page.php?id=xy  http://www.site.ru/new-page.php"
301 - status header, that browser gets first until it starts to load page.
 /old-page.php?id=xy - this is URL you want to redict from
 http://www.site.ru/new-page.php - and this is the url you want to redirect to.

See also this guides about .htaccess and mod_rewrite:
http://www.workingwith.me.uk/articles/scripting/mod_rewrite
http://www.blogstorm.co.uk/htaccess-mod_rewrite-ultimate-guide/

Author

Commented:
Just what I needed. Thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial