Reply to Re: redirect to directory - php redirect or htaccess?

Your name:

Reply:


Posted by Alan Little on 06/26/06 11:31

Carved in mystic runes upon the very living rock, the last words of deko
of comp.lang.php make plain:

> I'm trying to redirect requests for /index.php to
> /mydirectory/index.php
>
> If I use an index file in / with only this line:
>
> <?php header("Location:http://www.mysite.com/mydirectory/"); ?>
>
> that seems to work.

That will work, so long as that's all you want to redirect. However, if
someone visits http://www.mysite.com/mydirectory/someoldfile.php, it
won't.

> But can this be accomplished more efficiently with an htaccess
> rewrite?
>
> I already have this rewrite rule in my htaccess file:
> RewriteEngine on
> Options All -Indexes
> RewriteCond %{HTTP_HOST} ^www.myoldsite.com$ [NC,OR]
> RewriteCond %{HTTP_HOST} ^myoldsite.com$ [NC]
> RewriteRule ^(.*)$ http: //10.10.10.10/

> This just sends requests for myoldsite.com into hyperspace, but allows
> me to get email using that domain.

..htaccess has nothing to do with email, only web requests.

> 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

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/

[Back to original 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

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