1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Main Server IP + Main Domain problem

Discussion in 'Site & Server Administration' started by argothiusz, May 18, 2008.

  1. #1
    Normally when you type in the main server IP, it takes you to the Apache and Cpanel has instealled successfully page but for my case when I type in the main IP for my server, it re-direct me to my main domain name. How do you solve this problem?

    Thanks
     
    argothiusz, May 18, 2008 IP
  2. relixx

    relixx Active Member

    Messages:
    946
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    70
    #2
    Normally if you just type in the IP address, Apache shows you the contents of the default directory as it wasn't given a domain name.

    If it's automatically redirecting you to a domain (eg, you type in xxx.xxx.xxx.xxx and it redirects you to www . whatever. com) then it's most likely a redirect rule in place (either in the site's .conf file, a .htaccess file or in index.php) in the default www directory.

    If it's merely displaying the content of the main site, you'll need to change the settings for the default Apache www directory.
     
    relixx, May 18, 2008 IP
    argothiusz likes this.
  3. argothiusz

    argothiusz Well-Known Member

    Messages:
    1,500
    Likes Received:
    79
    Best Answers:
    0
    Trophy Points:
    140
    #3
    From the 2 cases you mentioned. I think it's case 1 but my main site .htaccess is blank and there is no config file on my main site.
    Beside, htaccess only effect when people actually type in the domain instead of IP. For instance, if I want people to auto redirect from MyDomain.com to www.MyDomain.com then I will edit my htaccess in MyDomain.com Public_html directory.

    I think it must have something to do with DNS Zone.
     
    argothiusz, May 18, 2008 IP
  4. eddy2099

    eddy2099 Peon

    Messages:
    8,028
    Likes Received:
    568
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Did you address the first site with a dedicated IP or a shared IP ?
     
    eddy2099, May 18, 2008 IP
    argothiusz likes this.
  5. relixx

    relixx Active Member

    Messages:
    946
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    70
    #5
    Look in the main Apache conf file, it'd probably be there then as like I said, if you type in just the IP address of the machine, Apache will return the default site configured on it.

    All .htaccess files do is allow you to use Apache directives at the directory level. You can do all sorts of redirects with them, not just those based on the domain name. Depending on how your server is setup, you could have redirect rules in an .htaccess file the default dir (normally something like /var/www/, /var/www/html/ or /var/www/apache/) or (more likely) in the main Apache conf file.

    No, by typing in the IP directly you are bypassing DNS altogether, as all DNS does is map IPs to domain names. The fact that you get redirected shows that the server itself is configured to do that :)
     
    relixx, May 18, 2008 IP
  6. argothiusz

    argothiusz Well-Known Member

    Messages:
    1,500
    Likes Received:
    79
    Best Answers:
    0
    Trophy Points:
    140
    #6
    Shared IP

    Where is it usually locate?
     
    argothiusz, May 18, 2008 IP
  7. relixx

    relixx Active Member

    Messages:
    946
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    70
    #7
    That depends on what flavour of linux you are using, and if you compiled from source or used a package manager. Assuming you used a package manager (yum, apt-get, etc), it'll always in be in /etc/, normally in a subdirectory like httpd or apache or apache2. The filename itself will be something like httpd.conf, apache.conf, apache2.conf
     
    relixx, May 18, 2008 IP
  8. argothiusz

    argothiusz Well-Known Member

    Messages:
    1,500
    Likes Received:
    79
    Best Answers:
    0
    Trophy Points:
    140
    #8
    I see httpd.conf in /usr/local/apache/conf/ so what line or what should I look for to change it?
     
    argothiusz, May 18, 2008 IP
  9. relixx

    relixx Active Member

    Messages:
    946
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    70
    #9
    What flavour of linux are you running? The setup of the conf file will be different depending on who compiled the package for which flavour.

    In the meantime, if /usr/local/apache/conf/httpd.conf is the config file (strange that it's not in /etc/ like it should be...) you could try look through it for something like "Section 2: 'Main' server configuration'.

    Hell, if you have SSH access (which you do by the sounds of things) you could just grep the file for the domain name, eg:

    grep -i "domain.com" /path/to/httpd.conf | grep -v "#"

    That command will search for lines containing domain.com (case insensitive) in the file /path/to/httpd.conf and then remove any commented-out lines.

    Although I'd highly advise you to not mess about with the httpd.conf file unless you know what you're doing.
     
    relixx, May 18, 2008 IP
  10. xous

    xous Active Member

    Messages:
    173
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #10
    Hi,

    This is occuring because your main domain is the default virtual host in the apache configuration file. It has likely become the default simply because it is the first vhost configured for that IP address.

    You need to move the virtual host what you want to be default above all the other virtual hosts for that IP address.
     
    xous, May 18, 2008 IP