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 deko on 12/04/84 11:51

>> 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.

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]


Thanks for the help!

 

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

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