On 25-05-2011 18:34, Webactor wrote:
> Hi there
>
> I have a small question about 301 redirect
> Ex. I would like til make a 301 redirect from a www. to a non-www
> domain.
>
> I found out that the code from non-www to www is:
> ----------------------------------------------------------------------------------------------
> <?php
> if (substr(getenv('HTTP_HOST'),0,3) != 'www')
> {
> header('HTTP/1.1 301 Moved Permanently');
> header('Location:
http://www.'.$_SERVER['HTTP_HOST'].
> $_SERVER['REQUEST_URI']);
> }
> ?>
> ----------------------------------------------------------------------------------------------
> But what do i do if its the other way around (from www to non-www) ?
> HTACCESS IS NOT AN ISSUE !! It has to be in php code.
>
> I Just cant find a way to redirect the other way around
> Hope you can help me
>
>
> You can check your 301 - code here:
>
http://www.ragepank.com/redirect-check/
>
>
> C yaaaa - Cheers
> kimo
You could take a look at substr_replace:
substr_replace ( $string , $replacement , $start, $length )
substr_replace (getenv'HTTP_HOST' , '' , 1 , 4 )
Karl Erik.
--
http://dmwebdesign.dk - DM i Webdesign
http://ranunkelvej.com/b&o/ - Reparation af B&O Red Line højttalere
http://webdesign.ranunkelvej.com - Artikler om webdesign