We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14258
    • 10 Posts
    Hello,

    I have a been building Modx sites for a while now, I use the same .htacess file (edited for each domain) and the Friendly URLs work wonderful. I’ve decided to start building sites under subdomains and have run into a few issues with the friendly URLs.

    Ex. subdomain.domain1234.com

    my current .htaccess looks like this

    [tt]Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^domain1234.com [NC]
    RewriteRule ^(.*)$ http://www.domain1234.com/$1 [L,R=301]

    # For full documentation and other suggested options, please see
    # http://svn.modxcms.com/docs/display/MODx096/Friendly+URL+Solutions
    # including for unexpected logouts in multi-server/cloud environments
    # and especially for the first three commented out rules

    #php_flag register_globals Off
    #AddDefaultCharset utf-8
    #php_value date.timezone Europe/Moscow

    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /

    # Fix Apache internal dummy connections from breaking [(site_url)] cache
    RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
    RewriteRule .* - [F,L]

    # Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin
    #RewriteCond %{HTTP_HOST} .
    #RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
    #RewriteRule (.*) http://www.example.com/$1 [R=301,L]

    # Exclude /assets and /manager directories from rewrite rules
    RewriteRule ^(manager|assets) - [L]

    # For Friendly URLs
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

    # Reduce server overhead by enabling output compression if supported.
    #php_flag zlib.output_compression On
    #php_value zlib.output_compression_level 5


    [/tt]

    When i try to add the subdomain ( subdomain.domain1234.com ) in the .htacess nothing works (site is broken)
    When the .htaccess is as it appears above everything works when I am under http://subdomain.domain1234.com however nothing works when I am http://www.subdomain.domain1234.com

    What can I do so that when I type in the www.subdomain.domain1234.com it will redirect to subdomain.domain1234.com ? rolleyes
      • 17883
      • 1,039 Posts
      Ex. subdomain.domain1234.com
      ->
      RewriteCond %{HTTP_HOST} .
      RewriteCond %{HTTP_HOST} !^subdomain\.domain1234\.com [NC]
      RewriteRule (.*) http://subdomain.domain1234.com/$1 [R=301,L]
      

      should work (remove your modifications on top).


        • 14258
        • 10 Posts
        Options +FollowSymLinks
        RewriteEngine on
        RewriteCond %{HTTP_HOST} .
        RewriteCond %{HTTP_HOST} !^subdomain\.domain1234\.com [NC]
        RewriteRule (.*) http://subdomain.domain1234.com/$1 [R=301,L]
        
        Options +FollowSymlinks
        RewriteEngine On
        RewriteBase /
        
        # Fix Apache internal dummy connections from breaking [(site_url)] cache
        RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
        RewriteRule .* - [F,L]
        
        RewriteRule ^(manager|assets) - [L]
        
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
        


        Thank you for the Reply.

        I have updated my .htacess (above). I am still having the same problems... again that is when I go to www.subdomain.domain1234.com the site is not found.. when its http://subdomain.domain1234.com everything works perfectly.

        I’m afraid people will try www.subdomain.domain1234.com and not find it. Any more suggestions?

        Thank You!
          • 17883
          • 1,039 Posts
          Try this:
          RewriteCond %{HTTP_HOST} ^www\. [NC]
          RewriteRule (.*) http://subdomain.domain1234.com/$1 [R=301,L]


          beneath the other rule.
            • 14258
            • 10 Posts
            Options +FollowSymLinks
            RewriteEngine on
            RewriteCond %{HTTP_HOST} .
            RewriteCond %{HTTP_HOST} !^subdomain\.domain1234\.com [NC]
            RewriteRule (.*) http://subdomain.domain1234.com/$1 [R=301,L]
            RewriteCond %{HTTP_HOST} ^www\. [NC]
            RewriteRule (.*) http://subdomain.domain1234.com/$1 [R=301,L]
            
            
            Options +FollowSymlinks
            RewriteEngine On
            RewriteBase /
            
            # Fix Apache internal dummy connections from breaking [(site_url)] cache
            RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
            RewriteRule .* - [F,L]
            
            RewriteRule ^(manager|assets) - [L]
            
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
            


            Still no luck! the www.subdomain.domain1234.com is not found... I wonder if this could have something to do with the hosting. In my hosting account the subdomain is pointed to a new directory, but then again the site does work except for the www. issue.

            Any other ideas?
              • 19370
              • 24 Posts
              to see if it is related to your hosting, rename the .htaccess to ht.access and put a file like myfile.html in your root dir, then try:
              http://subdomain.domain.com/myfile.html
              http://www.subdomain.domain.com/myfile.html

              if you can access the file with booth links, it is related with your htaccess, else, it’s hosting dns problem.

              tel me something to help you.

              José Moreira
                • 14258
                • 10 Posts
                Just tried that... same issues so I’m going to give my webhosting company a ring. I’ll post the results.

                Thank you!