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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация