• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Website (subdomain?) Question

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #11
    Originally posted by darrylmg View Post
    I would avoid using .htaccess files if I were you. Much safer to use CNAME records.
    Humm I thought I had to do both.

    I tried creating a CNAME record like this:
    Code:
    www.subdomain.example.com subdomain.example.com
    I tried creating an A record like this:
    Code:
    www.example.com 99.99.99.99
    subdomain.example.com 99.99.99.99
    www.subdomain.example.com 99.99.99.99
    Then in .htaccess I have this
    Code:
    RewriteCond %{HTTP_HOST} ^www.subdomain.example.com
    RewriteRule ^(.*) http://subdomain.example.com [R=301,L]
    Ah but which .htaccess I hear you ask. On the web server when I FTP in, I see this structure:

    a file called .htaccess (this is the one where I have added the rewrite stuff)
    a folder called www
    a folder called subdomain
    a folder called cgi-bin

    In the subdomain folder there is a standard wordpress .htaccess file to whoch I have added so now it looks like this:

    Code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.subdomain.example.com
    RewriteRule ^(.*) http://subdomain.example.com [L]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    But without access to the Apache logs I can't get any insight as to how far it's getting before failing.

    EDIT: added code tags to stop forum software mangling my post
    Last edited by Platypus; 23 June 2014, 14:30.

    Comment


      #12
      An update, hoping this might help you help me !

      I have a CNAME record which directs

      www. subdomain.example.com to subdomain.example.com

      I think it's working because if I ping subdomain.example.com and www. subdomain.example.com they both return the same IP address.

      But what I don't understand is what's happening when I visit the site. I deliberately broke the .htaccess file so that if I visit subdomain.example.com I get an error. But when I visit www. subdomain.example.com I don't get the error, I get redirected to the hoster's default "the domain name has been registered with us blah blah" page. So it's as if a visit to www. subdomain.example.com isn't "arriving" at the web server.

      Any ideas gratefully received. This must be SO common I'm amazed that Google hasn't found me a simple answer.

      Thanks!

      Comment


        #13
        Originally posted by Platypus View Post
        Humm I thought I had to do both.

        I tried creating a CNAME record like this:
        Code:
        www.subdomain.example.com subdomain.example.com
        I tried creating an A record like this:
        Code:
        www.example.com 99.99.99.99
        subdomain.example.com 99.99.99.99
        www.subdomain.example.com 99.99.99.99
        Then in .htaccess I have this
        Code:
        RewriteCond %{HTTP_HOST} ^www.subdomain.example.com
        RewriteRule ^(.*) http://subdomain.example.com [R=301,L]
        Ah but which .htaccess I hear you ask. On the web server when I FTP in, I see this structure:

        a file called .htaccess (this is the one where I have added the rewrite stuff)
        a folder called www
        a folder called subdomain
        a folder called cgi-bin

        In the subdomain folder there is a standard wordpress .htaccess file to whoch I have added so now it looks like this:

        Code:
        # BEGIN WordPress
        <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^www.subdomain.example.com
        RewriteRule ^(.*) http://subdomain.example.com [L]
        RewriteBase /
        RewriteRule ^index\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
        </IfModule>
        
        # END WordPress
        But without access to the Apache logs I can't get any insight as to how far it's getting before failing.

        EDIT: added code tags to stop forum software mangling my post
        Is there anyway that you can verify that mod_rewrite has been loaded into Apache?
        If your hosting provider have excluded it from the allowed modules, then it won't work.
        Don't believe it, until you see it!

        Comment


          #14
          Also, the .htaccess you've created needs to go in the www folder, not the subdomain folder.
          Your Apache is probably setting up the document root for www to be the www directory.

          Edit: should be the www folder underneath "subdomain" folder.
          Last edited by darrylmg; 24 June 2014, 07:47.
          Don't believe it, until you see it!

          Comment


            #15
            This is what I think is happening.

            - you enter www.subdomaon.example.com in web browser.
            - web browser requests a dns lookup to get the ip address. This correctly returns the ip as you have said.
            - your web browser requests the default page at "/" which is the document root for the http address.
            - Apache is receiving your browser's request and accewsing the document root for www.subdomain.example.com, which is probably "/subdomain/www".
            - since there is no default page at that location (index.htm, index.html etc) the default hosting company page is kicking in.

            HTH
            Don't believe it, until you see it!

            Comment


              #16
              Originally posted by Platypus View Post
              An update, hoping this might help you help me !

              I have a CNAME record which directs

              www. subdomain.example.com to subdomain.example.com

              I think it's working because if I ping subdomain.example.com and www. subdomain.example.com they both return the same IP address.

              But what I don't understand is what's happening when I visit the site. I deliberately broke the .htaccess file so that if I visit subdomain.example.com I get an error. But when I visit www. subdomain.example.com I don't get the error, I get redirected to the hoster's default "the domain name has been registered with us blah blah" page. So it's as if a visit to www. subdomain.example.com isn't "arriving" at the web server.

              Any ideas gratefully received. This must be SO common I'm amazed that Google hasn't found me a simple answer.

              Thanks!
              It sounds like you have the DNS side of it sorted.

              Can you get Apache error logs from the server?

              Apache needs to know about www. subdomain.example.com with a <VirtualHost> block as per your previous snippet. Is there already one of these for the plain www. example.com domain?

              When you visit www. example.com does it actually redirect to example.com (or vice versa), i.e. the URL in the browser bar consistently changes to one or the other? Or, is the same page available under those two separate addresses? This is the difference between using redirects and rewrites afaik, with redirects being the preferred mechanism.

              I would use wget (or similar) to query the url and trace what's happening from there.

              Comment


                #17
                Originally posted by darrylmg View Post
                This is what I think is happening.

                - you enter www.subdomaon.example.com in web browser.
                - web browser requests a dns lookup to get the ip address. This correctly returns the ip as you have said.
                - your web browser requests the default page at "/" which is the document root for the http address.
                - Apache is receiving your browser's request and accewsing the document root for www.subdomain.example.com, which is probably "/subdomain/www".
                - since there is no default page at that location (index.htm, index.html etc) the default hosting company page is kicking in.

                HTH
                Thanks. Good suggestion but it didn't work. I think you're on the right lines but the document that Apache is trying to access isn't at www.subdomain.example.com. This is the HTTP response I'm getting:

                Code:
                HTTP/1.1 404 Not Found 
                Date: Tue, 24 Jun 2014 08:29:03 GMT 
                Server: Apache/2.2.3 (CentOS) 
                Connection: close 
                Content-Type: text/html; charset=ISO-8859-1
                Without access to the error log file it's hard to guess what's happening!

                The directory structure I have is:

                /
                /cgi-bin
                /subdomain
                /www

                I have a deliberately broken .htaccess in all but cgi-bin and I'm not getting an error. I've also tried that in /subdomain/www/

                I've raised a ticket with easyspace

                Comment


                  #18
                  Have you tried putting and index.html page in the /subdomain/www directory?
                  Don't believe it, until you see it!

                  Comment


                    #19
                    Originally posted by darrylmg View Post
                    Have you tried putting and index.html page in the /subdomain/www directory?
                    Just tried it. Nothing

                    Comment

                    Working...
                    X