You are here: Re: redirect to directory - php redirect or htaccess? « PHP Programming Language « IT news, forums, messages
Re: redirect to directory - php redirect or htaccess?

Posted by Richard Levasseur on 12/17/83 11:51

deko wrote:
> >> How do I append to htaccess so that I can redirect requests for a
> >> specific host to a particular directory?
> >
> > RewriteCond %{HTTP_HOST} ^www.example.com$
> > RewriteCond %{REQUEST_URI} !^/example/
> > RewriteRule (.*) /example/$1
> >
> > RewriteCond %{HTTP_HOST} ^example.com$
> > RewriteCond %{REQUEST_URI} !^/example/
> > RewriteRule (.*) /example/$1
>
> Thanks - that helps.
>
> A couple of follow-up questions:
>
> Should I escape the periods in HTTP_HOST?
>
> RewriteCond %{HTTP_HOST} ^www\.example\.com$
>
> I assume that if I DO NOT escape them, then I would also match:
>
> wwwXexample.com
>
> or
>
> www.exampleYcom
>
> or both.
>

Most likely not. The browser will look for the domain wwwXexample.com
instead of example.com. the same is true for www.exampleYcom. The
only thing that it could ever really match is a period because of how
it has to be formatted.

> Also, what do you think about the value of rewriting urls without the "www"?
>
> RewriteEngine on
> RewriteBase /
>
> RewriteCond %{HTTP_HOST} ^www\.example\.com$
> RewriteRule (.*) http://example.com/$1 [R=Permanent]
>
>

Haha, did you read the conversatron by chance?

 

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

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