View Full Version : appointing domain to a file (other than index)
jusko
June 4th, 2007, 12:48 PM
Hi!!!
I have a question:
Is it possible to appoint a domain (ex:www.mynewdomain.com) to a specific file in a server instead of the index file?
I have already a domain (www.mydomain.com (http://www.mydomain.com)) appointing to that server using the index.html file.
It's kinda having two websites in the save server. One domain appointing to the index.html file, and the other domain appointing to a different file....
hope i made myself clear on this one :)
I heard that i could do this with a php script
thanks a lot!!!
cheers
simplistik
June 4th, 2007, 02:06 PM
no you can't... www.mydomain.com can not possibly link to two different files at the same time. there are other options:
use a subdomain, something.mydomain.com
use a subfolder, www.mydomain.com/something
link to the file, www.mydomain.com/something.extension
sekasi
June 4th, 2007, 02:19 PM
No, thats not right. You can point domain names to specific files with the standard IIS.
eirche
June 4th, 2007, 02:20 PM
use _SERVER["HTTP_HOST"] to see which domain.
netrix
June 4th, 2007, 08:50 PM
yes u can... all u need its an htaccess file to redirect each specific domain you have to a folder inside your server... currently i have like 5 domains into my same hosting account, all of them pointing to different folders.
simplistik
June 4th, 2007, 10:14 PM
right, 5 different domains to 5 different files... not 1 domain to 5 files... basically he asked if...
www.domain.com can point to file 1 as well as file 2
jusko
June 5th, 2007, 01:50 PM
<?php
if ($_SERVER['HTTP_HOST'] == "www.mydomain2.com (http://www.mydomain2.com)") {
$to = 'http://www.mydomain/new/file.html';
header('Location: '. $to);
exit();
}
?>
I tried this and didnŽt work...
The thing is if someone types www.mydomain.com (http://www.mydomain.com), the page thap appears would be 'http://www.mydomain/firstfile.html
if someone types www.mydomain2.com (http://www.mydomain2.com) the page that shoul open is
'http://www.mydomain/new/file.html'
What am I doing wrong?
simplistik
June 5th, 2007, 02:35 PM
well in your $to variable you need to have mydomain.com not just mydomain, but what you have there should work fine.
just outta curiosity... i notice that you're redirecting to .html files, what's the extension of the file you're trying to add that php to? if it's not a .php file then it won't read that as a php command...
ramie
June 5th, 2007, 02:58 PM
he asked if "domain one" can point to "file one" and "domain two" to "file two"...
It's kinda having two websites in the save server. One domain appointing to the index.html file, and the other domain appointing to a different file....
use an .htaccess file to do this properly, not php as your redirection will be tied to a serverside language, this is not cool... have a read at the link below for some htaccess info.
http://enarion.net/web/apache/htaccess/redirect-domain-to-file/
jusko
June 6th, 2007, 06:38 AM
The file where i put this php is index.php. By default, www.mydomain.com (http://www.mydomain.com) and my www.mynewdomain.com (http://www.mynewdomain.com) both pointed to index.html.
I changed index.html to index.php so i can put the code i need. I tried the following...
<?php
if ($_SERVER['HTTP_HOST'] == "www.mydomain.com") {
$to = 'http://www.mydomain.com/first.html';
header('Location: '. $to);
exit;
}
if ($_SERVER['HTTP_HOST'] == "www.mynewdomain.com") {
$to = 'http://www.mydomain.com/newfolder/second.html';
header('Location: '. $to);
exit;
}
?>
but, both www.mydomain.com (http://www.mydomain.com) and www.mynewdomain.com (http://www.mynewdomain.com) now point to www.mydomain.com/first.html (http://www.mydomain.com/first.html)
I'm a bit lost as you can understand....
thanks for all the help!
simplistik
June 6th, 2007, 08:50 AM
here man I just tested this code and it works fine
<?
if ($_SERVER['HTTP_HOST'] == 'www.beyondthepixel.com' )
{
$to = 'http://www.kirupa.com';
header('Location: '. $to);
exit();
}
elseif ($_SERVER['HTTP_HOST'] == 'dev.beyondthepixel.com' )
{
$to = 'http://www.beyondthepixel.com';
header('Location: '. $to);
exit();
}
?>
jusko
June 7th, 2007, 11:34 AM
Thank you Simplistik for your time!
Put the code you gave me, but still doesnŽt work. Both domains still open the same file.
IŽll contact the hosting provider to see if the problem is with the server. Because when I registered both domains I told them (the hosting company) to point the domains to the same index file. This is very strange why this doesnŽt work.
but again, thank you so much!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.