You are here: Re: Redirecting URL ID's using PHP « All PHP « IT news, forums, messages
Re: Redirecting URL ID's using PHP

Posted by Arjen on 06/15/07 08:26

Armand Brahaj wrote:
> kevgibbo wrote:
>> Hi,
>>
>> I've recently updated a website and I'd like to redirect some ID URL's
>> using PHP code, I know how to do the redirect part the problem is the
>> if statement to only redirect url's with an id.
>>
>> for example:
>> if domain is www.domain.com do nothing
>> but if domain is www.domain.com/?p=12 redirect to www.domain.com
>>
>> Thanks in advance,
>> Kevin
>> www.seoptimise.com
>>
> You can do it with headers.
> if ($_GET["p"]==12)
> {
> header("Location: http://www.domain12.com/");
> exit;
> }
>
> Of yourse, you should handle the $_GET variables well (check for any
> security issues and validation.
> Probably create a switch function that will switch for all your values
> (so you don't use switch for large number of domain redirects).
> Don't forget to put this code at the very begining of the PHP FIle.
>

Sounds to me that some pages are no longer available or have moved.

Use correct headers with this or your search enigne results will drop
like a stone :-(

//Moved pages
header("HTTP/1.0 301 Moved Permanently");
header("Location: newpage.php");

// page doesn't exist
header("HTTP/1.0 404 Not Found");
exit;

--
Arjen
http://www.arjenkarel.nl

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация