.htaccess help

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/
 

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]
 
F

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>
 

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.
 
F

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.
 

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?
 
F

Floris

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

sparky5693

Active member
RewriteCond %{HTTP_HOST} !^xenfans.com/forums/$ [NC]
RewriteRule ^(.*)$ http://xenfans.com/forums/$1 [L,R=301]
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>
 

CTXMedia

Formerly CyclingTribe
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>
You've missed the ending slash from the second line:

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

Cheers,
Shaun :D
 

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>
 

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>
 

sparky5693

Active 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>
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.
 
Top