Forum Moderators: phranque

Message Too Old, No Replies

Domain based redirect to different PHP files via htaccess

         

paespedro

3:23 pm on Aug 18, 2010 (gmt 0)

10+ Year Member



Hello there. Here's the thing: I have two domains here [http://www.myproject.com and [http://www.myproject.com.br .. In my root folder i have all the stuff for my projects including two "indexes": "index-en.php" for english and "index.php" for portuguese.

Can i have some trick in htaccess that redirect my users to one of these files depending on domain? .. something like:

[http://www.myproject.com [OR] [http://myproject.com redirect to [http://www.myproject.com/index-en.php

and

[http://www.myproject.com.br [OR] [http://myproject.com.br redirect to [http://www.myproject.com.br/index.php

?

Sorry if this is a stupid question but im almost crazy looking for tutorials over the internet and i cant get something that works, os some response if this is possible or just a stupid question .. Can someone please give me some direction?

thanks a lot

Actually i have this in my .htaccess:


ErrorDocument 404 /404.php


#Options +FollowSymLinks
RewriteEngine On
RewriteBase /


RewriteCond %{HTTP_HOST} ^myproject.com$ [NC]
RewriteRule ^(.*)$ http://www.myproject.com/index-en.php [R=301,L]

RewriteCond %{HTTP_HOST} ^myproject.com.br$ [NC]
RewriteRule ^(.*)$ http://www.myproject.com.br/ [R=301,L]


This just does the "non www to www" - that works correctly


Thanks

paespedro

1:39 am on Aug 19, 2010 (gmt 0)

10+ Year Member



I have it OK now. Many thanks Tim!
If someone needs this too the answer is here: [stackoverflow.com...]