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

.htaccess help

Discussion in 'XenForo Questions and Support' started by sparky5693, Sep 4, 2011.

  1. sparky5693

    sparky5693 Active Member

    I'm looking to remove the www's... In my root folder, my .htaccess looks like this:
    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^theshaveden.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.theshaveden.com$
    RewriteRule ^/?$ "http\:\/\/www\.theshaveden\.com\/forums\/portal" [R=301,L]
    
    Yet this deeper link isn't changed. Can you guys give me some tips on what i'm doing wrong?
    http://www.theshaveden.com/forums/forums/the-medicine-cabinet.55/
     
  2. Slavik

    Slavik XenForo Moderator Staff Member

    Try this.

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
    RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
    
     
  3. sparky5693

    sparky5693 Active Member

    Would this also recurse into subdirectories?
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yes.
     
  5. Floris

    Floris Guest

    This is what I use on XenFans, which seems to work

    Code:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^xenfans.com$ [NC]
    RewriteRule ^(.*)$ http://xenfans.com/$1 [L,R=301]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data|js|styles|install) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    </IfModule>
     
  6. sparky5693

    sparky5693 Active Member

    Nope, that didn't do it either. Lemme be sure, this goes into the root directory of the server, not in the folder containing xenforo, yes?

    I've tried both explorer and firefox, even cleared my cache just to be sure.
     
  7. Floris

    Floris Guest

    If you have your upload/* from xenforo, that's where it goes.
    so when you view the dir, you have xenforo's index.php a dir called library/ and a few other things, and .. the .htaccess one.
     
  8. sparky5693

    sparky5693 Active Member

    Well that makes all the difference then. I've been placing this just inside the publichtml folder, while the forum is installed inside /forums. Do I edit this into the xenforo htaccess file, or would this replace it entirely?
     
  9. Floris

    Floris Guest

    You can replace the content.
    Don't forget to change the domain to yours of course.
     
  10. sparky5693

    sparky5693 Active Member

  11. Floris

    Floris Guest

  12. sparky5693

    sparky5693 Active Member

    I used this, and it knocked the website offline.
    Code:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^theshaveden.com/forums$ [NC]
    RewriteRule ^(.*)$ http://theshaveden.com/forums/$1 [L,R=301]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data|js|styles|install) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    </IfModule>
     
  13. Floris

    Floris Guest

    Sorry, then I don't know.
     
  14. CyclingTribe

    CyclingTribe Well-Known Member

    You've missed the ending slash from the second line:

    RewriteEngine On RewriteCond %{HTTP_HOST} !^theshaveden.com/forums/$ [NC]

    Cheers,
    Shaun :D
     
  15. sparky5693

    sparky5693 Active Member

    Yup... I certainly did. Unfortunately, it didn't help. When I use the code below, the forum won't even load.
    Code:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^theshaveden.com/forums/$ [NC]
    RewriteRule ^(.*)$ http://theshaveden.com/forums/$1 [L,R=301]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data|js|styles|install) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    </IfModule>
     
  16. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I know this code works. Just modify it to specify your domain. Try this code:

    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
    
        RewriteCond %{HTTP_HOST} ^www.theshaveden.com/forums$ [NC]
        RewriteRule ^(.*)$ http://theshaveden.com/forums/$1 [R=301,L]
    
        #    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
    
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data|js|styles|install) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
    </IfModule>
    
     
  17. sparky5693

    sparky5693 Active Member

    Isn't working at all in firefox (manually cleared cache). In explorer, it's not removing the www, but it is maintaining my login info across www and non www. I feel like i'm missing something incredibly simple here.
     
  18. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I can take a look if you are comfortable giving me your FTP and admin info.
     
  19. kuyenmotdivad

    kuyenmotdivad Active Member

    You know the forum URL in your XenForo install / admin panel its not set to www is it?
     
  20. sparky5693

    sparky5693 Active Member

    No such luck.
     

Share This Page