You are here: Re: want to use php to alternate links « PHP Language « IT news, forums, messages
Re: want to use php to alternate links

Posted by Veikko M�kinen on 06/02/05 17:48

Peter Van Hove wrote:
> 1.
> Static yes. Understood. Changing everything is not an option right now
> because I need the same page-names and extensions for
> link-from-outside-purposes.
> If I change them to php all the links to these pages will be lost.
>

How about still changing them and handling 404 error with php?

Here is the trick for Apache:

#file /home/user/public_html/.htaccess
ErrorDocument 404 /404.php

#file /home/user/public_html/404.php
<?
$www = $_SERVER['DOCUMENT_ROOT'];
$path = dirname($_SERVER['REQUEST_URI']);
$file = basename($_SERVER['REQUEST_URI'], '.html');

if (file_exists($www.$path.$file.'html'))
{
header('HTTP/1.1 301 Moved Permanently');
header("Location: http://{$_SERVER['HTTP_HOST']}{$path}{$file}.php");
}
else
header("HTTP/1.0 404 Not Found");

?>

Didn't test it, but you'll get the idea anyway :)


-veikko

--
veikko
mail@ .com
makinen

 

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

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