1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 Setting Preferred Domain

Discussion in 'Troubleshooting and Problems' started by akhilaniyan, Oct 24, 2014.

  1. akhilaniyan

    akhilaniyan Active Member

    Hi.

    I have installed the forum on the subdomain. So, from google webmasters, I'm unable to set the preferred domain.

    I know, this is a frequent question. I have tried to add the preferred domain redirection code in .htaccess file. But, it is not working. I think I've made a mistake. Please help me to resolve the below issues:
    1. How to redirect from "www.forum.tidblog.com" to "forum.tidblog.com" ?

    2. How to remove all links of "www.forum.tidblog.com" from google search results (Without hurting my main domain)? Because, google indexed the both versions of my forum!
    Please review the mistake of my code in the .htaccess file:

    Code:
    #    Mod_security can interfere with uploading of content such as attachments. If you
    
    #    cannot attach files, remove the "#" from the lines below.
    
    #<IfModule mod_security.c>
    
    #    SecFilterEngine Off
    
    #    SecFilterScanPOST Off
    
    #</IfModule>
    
    ErrorDocument 401 default
    
    ErrorDocument 403 default
    
    ErrorDocument 404 default
    
    ErrorDocument 500 default
    
    <IfModule mod_rewrite.c>
    
        RewriteEngine On
    
        #    If you are having problems with the rewrite rules, remove the "#" from the
    
        #    line that begins "RewriteBase" below. You will also have to change the path
    
        #    of the rewrite to reflect the path to your XenForo installation.
    
        #RewriteBase /xenforo
    
        #    This line may be needed to enable WebDAV editing with PHP as a CGI.
    
        #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
        RewriteCond %{REQUEST_FILENAME} -f [OR]
    
        RewriteCond %{REQUEST_FILENAME} -l [OR]
    
        RewriteCond %{REQUEST_FILENAME} -d
    
        RewriteRule ^.*$ - [NC,L]
    
        RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    
        RewriteRule ^.*$ index.php [NC,L]
       
        RewriteCond %{HTTP_HOST} ^www.forum.tidblog\.com$ [NC]
        RewriteRule ^(.*)$ http://forum.tidblog.com/$1 [R=301,L]
    
    </IfModule>
    Thanks.
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Custom rewrites such as that must come before the XenForo rewrite rules.
     
  3. akhilaniyan

    akhilaniyan Active Member

    Is this correct?

    Code:
       
        RewriteEngine On
    
        RewriteCond %{HTTP_HOST} ^www.forum.tidblog\.com$ [NC]
       
        RewriteRule ^(.*)$ http://forum.tidblog.com/$1 [R=301,L]
    
    #    Mod_security can interfere with uploading of content such as attachments. If you
    
    #    cannot attach files, remove the "#" from the lines below.
    
    #<IfModule mod_security.c>
    
    #    SecFilterEngine Off
    
    #    SecFilterScanPOST Off
    
    #</IfModule>
    
    
    
    ErrorDocument 401 default
    
    ErrorDocument 403 default
    
    ErrorDocument 404 default
    
    ErrorDocument 500 default
    
    
    <IfModule mod_rewrite.c>
    
    
        RewriteEngine On
    
    
    
        #    If you are having problems with the rewrite rules, remove the "#" from the
    
        #    line that begins "RewriteBase" below. You will also have to change the path
    
        #    of the rewrite to reflect the path to your XenForo installation.
    
        #RewriteBase /xenforo
    
    
    
        #    This line may be needed to enable WebDAV editing with PHP as a CGI.
    
        #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
       
        RewriteCond %{REQUEST_FILENAME} -f [OR]
    
        RewriteCond %{REQUEST_FILENAME} -l [OR]
    
        RewriteCond %{REQUEST_FILENAME} -d
    
        RewriteRule ^.*$ - [NC,L]
    
        RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    
        RewriteRule ^.*$ index.php [NC,L]
    
    </IfModule>
    Still not working!
     

Share This Page