Newb: How to redirect from domain.com to www.domain.com

Discussion in 'Installation/Configuration' started by smartin, Feb 17, 2010.

  1. smartin

    smartin New Member

    Hi,

    I have ISPc3 running on Ubuntu 8.04 LTS.

    On one of my sites I have Drupal installed. I noticed that when I go to http://domain.com I just get the default apache 'It works!' page.

    How do I redirect this page to my site on http://www.domain.com?

    in the .htaccess file at the root of the /web directory I have:
    Code:
    # Various rewrite rules.
    <IfModule mod_rewrite.c>
      RewriteEngine on
    
      # If your site can be accessed both with and without the 'www.' prefix, you
      # can use one of the following settings to redirect users to your preferred
      # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
      #
      # To redirect all users to access the site WITH the 'www.' prefix,
      # (http://example.com/... will be redirected to http://www.example.com/...)
      # adapt and uncomment the following:
      RewriteCond %{HTTP_HOST} ^mydomain\.co.uk$ [NC]
      RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 [L,R=301]
    This isn't doing the job. What else do I need to do? (www.mydomain.co.uk is the domain I'm using...)

    The apache mod_rewrite module is enabled.

    Thanks :)

    S
     
    Last edited: Feb 17, 2010
  2. frument

    frument New Member

    You can add it from the ISPC3 admin panel.

    Sites > yourdomain.com > Auto Subdomain: Drop down to www.
     
  3. BorderAmigos

    BorderAmigos New Member

    The Drupal rewrites work, I have them in several sites. It looks more like your DNS isn't set up correctly. If you are going to the /var/www. instead of the /var/www/somedomain.com/web/.

    In your DNS make sure you have A records for mydomain.co.uk. (dot at end) and www (no dot at end) both pointing to your IP address.
     
  4. smartin

    smartin New Member

    frument,

    That didn't do it... Probably a DNS thing as BorderAmigos is saying.

    Thanks though!

    S
     
  5. smartin

    smartin New Member

    BorderAmigos,

    I should have though of the DNS...

    My provider allows me to control things in this way:
    entry box | .domain (fixed) | Dropdown menu for Type | entry box for ip address

    I did have set:
    blank box | .domain | A record | my Ip address
    * |.domain | A record | my IP address

    Now I have:
    * | .domain | A record | my IP address
    www | .domain | A record | my IP address.

    Is that going to do the job?

    I thought <blank>.domain would already have sent everything to my IP...?

    Have to wait 24h to see... :)

    S
     
  6. BorderAmigos

    BorderAmigos New Member

    Are you using ISPConfig 3? You should just be able to add an A record in DNS under the Records tab. Here is an example of the DNS records I have set in ISPConfig3 DNS for each domain name...

    Type Name Data Priority...

    A host 123.123.123.123 0
    A mail 123.123.123.123 0
    A ns1 123.123.123.123 0
    A ns2 123.123.123.123 0
    A example.com. 123.123.123.123 0
    A www 123.123.123.123 0
    CNAME css example.com. 0
    CNAME img example.com. 0
    CNAME js example.com. 0
    CNAME tryout example.com. 0
    MX example.com. host.example.com. 10
    NS example.com. ns1.example.com. 0
    NS example.com. ns2.example.com. 0
    TXT example.com. v=spf1 mx -all 0 0

    (The CNAMES are for specific Drupal modules I use and not required for everything).
     
    Last edited: Feb 17, 2010
  7. smartin

    smartin New Member

    BorderAmigos,

    I'm really sorry. I wasn't clear... I'm not using ISPc3 for DNS. My registrar is handling it.

    I'll see in another 18h or so if things are working.

    Really appreciate you putting me on the right track.

    S
     
  8. smartin

    smartin New Member

    Still not working...

    Hi,

    Hmmm, just been on the phone to the people handling the DNS and they say the DNS is set up correctly but things are still not working properly.

    Can anyone think what I'm doing wrong still? The issue seems to be with my setup.

    S
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Does:

    ping www.yourdomain.com

    when you execute it on your workstation return the corect IP address of your server? the same IP that you get when you run:

    ping yourdomain.com
     
  10. smartin

    smartin New Member

    Hi Till,

    Yes, both www.mydomain.co.uk and mydomain.co.uk pings the correct IP address.

    Any thoughts on where my problem lies?

    S
     
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    Please post the content of the vhost file of this website.
     
  12. smartin

    smartin New Member

    Till,

    I hope it's
    Code:
    <Directory /var/www/www.mydomain.co.uk>
        AllowOverride None
        Order Deny,Allow
        Deny from all
    </Directory>
    
    <VirtualHost *:80>
          DocumentRoot /var/www/www.mydomain.co.uk/web
      
        ServerName www.mydomain.co.uk
        ServerAlias www.www.mydomain.co.uk
        ServerAdmin [email protected]
    
        ErrorLog /var/log/ispconfig/httpd/www.mydomain.co.uk/error.log
    
        ErrorDocument 400 /error/400.html
        ErrorDocument 401 /error/401.html
        ErrorDocument 403 /error/403.html
        ErrorDocument 404 /error/404.html
        ErrorDocument 405 /error/405.html
        ErrorDocument 500 /error/500.html
        ErrorDocument 503 /error/503.html
    
        <Directory /var/www/www.mydomain.co.uk/web>
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
        <Directory /var/www/clients/client2/web2/web>
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    
        # mod_php enabled
        AddType application/x-httpd-php .php .php3 .php4 .php5
        php_admin_value sendmail_path "/usr/sbin/sendmail -t -i [email protected]"
        php_admin_value upload_tmp_dir /var/www/clients/client2/web2/tmp
        php_admin_value session.save_path /var/www/clients/client2/web2/tmp
    
    
    </VirtualHost>
    
    
    
    <IfModule mod_ssl.c>
    ###########################################################
    # SSL Vhost
    ###########################################################
    
    <VirtualHost *:443>
          DocumentRoot /var/www/www.mydomain.co.uk/web
      
        ServerName www.mydomain.co.uk
        ServerAlias www.www.mydomain.co.uk
        ServerAdmin [email protected]
        
        ErrorLog /var/log/ispconfig/httpd/www.mydomain.co.uk/error.log
    
        ErrorDocument 400 /error/400.html
        ErrorDocument 401 /error/401.html
        ErrorDocument 403 /error/403.html
        ErrorDocument 404 /error/404.html
        ErrorDocument 405 /error/405.html
        ErrorDocument 500 /error/500.html
        ErrorDocument 503 /error/503.html
    
        SSLEngine on
        SSLCertificateFile /var/www/clients/client2/web2/ssl/www.mydomain.co.uk.crt
        SSLCertificateKeyFile /var/www/clients/client2/web2/ssl/www.mydomain.co.uk.key
        
            <Directory /var/www/www.mydomain.co.uk/web>
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
        <Directory /var/www/clients/client2/web2/web>
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    
        # mod_php enabled
        AddType application/x-httpd-php .php .php3 .php4 .php5
        php_admin_value sendmail_path "/usr/sbin/sendmail -t -i [email protected]"
        php_admin_value upload_tmp_dir /var/www/clients/client2/web2/tmp
        php_admin_value session.save_path /var/www/clients/client2/web2/tmp
    
    
    </VirtualHost>
    </IfModule>
    
     
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    You entered the domain with ww in front which is wrong. Please change ww.domain.com in the website settings to domain.com and click on save.
     
  14. smartin

    smartin New Member

    Till,

    Thanks! :)

    Kicked in after I restarted apache.

    S
     

Share This Page