php statement to redirect browser based on page id

BCrawler used Ask the Experts™
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

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.

Watch Question

Do more with

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

did u try this one header()

if($id ='xy')
$uri = "";

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"
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 - and this is the url you want to redirect to.

See also this guides about .htaccess and mod_rewrite:


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