Home > Archive > PHP Language > May 2006 > Domain redirect
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Bartosz Zoltak 2006-05-07, 7:01 pm |
| I am a beginner in php. I have two domains connected to the
same server. After typing in the browser either
www.domain1.com or www.domain2.com the same file index.php
is displayed.
Is it possible to do it this way that after typing
www.domain1.com the file index1.php would be displayed and
after typing www.domain2.com - index2.php?
Thanks a lot for help,
Barosz
www.vmpcfunction.com
| |
| Ian Pawson 2006-05-07, 7:01 pm |
| Bartosz Zoltak wrote:
> I am a beginner in php. I have two domains connected to the
> same server. After typing in the browser either
> www.domain1.com or www.domain2.com the same file index.php
> is displayed.
>
> Is it possible to do it this way that after typing
> www.domain1.com the file index1.php would be displayed and
> after typing www.domain2.com - index2.php?
>
> Thanks a lot for help,
>
> Barosz
>
> www.vmpcfunction.com
>
>
>
If you are using apache then have a look at 'virtual hosts' in the .conf
file. I run 4 different sites on the same physical server.
| |
| Danny Wong 2006-05-11, 7:57 am |
| Hi,
If you can't change the httpd.conf (most likely you can't if you are
using virtual hosting service), you can create an index.php and then test
the domain name that call this file. After you get the domain name you can
point them to the proper folder or file that contains different site pages.
The following sample can do what you wants, please be careful not to
output anything in your code before the header() function, otherwise it will
not work.
file:index.php
<?php
$server = $_SERVER['SERVER_NAME'] ;
if ($server == 'www.domain1.com') :
header("Location: http://www.domain1.com/index1.php");
else :
header("Location: http://www.domain2.com/index2.php");
endif ;
?>
However, I prefer to setup two folders to hold the 2 sites pages and use
http://www.domain1.com/domain1/index.php. This way you can create your
pages with relative path that will not mess up things.
Hopes this help.
Danny
VHOST NETWORK SUPPORT
support@vhosthk.com
"Bartosz Zoltak" <bzoltak@wp.pl> ¼¶¼g©ó¶l¥ó·s»D:e3k91k$29d$1@nemesis.news.tpi.pl...
>I am a beginner in php. I have two domains connected to the
> same server. After typing in the browser either
> www.domain1.com or www.domain2.com the same file index.php
> is displayed.
>
> Is it possible to do it this way that after typing
> www.domain1.com the file index1.php would be displayed and
> after typing www.domain2.com - index2.php?
>
> Thanks a lot for help,
>
> Barosz
>
> www.vmpcfunction.com
>
>
>
|
|
|
|
|