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

Redirecting www to non-www

Carl

Well-known member
#1
Can someone please clarify how to specify the file to remove the www. i havent been able to get it to work the other way around. Thanks :)
 

Brett Peters

Well-known member
#2
Can someone please clarify how to specify the file to remove the www. i havent been able to get it to work the other way around. Thanks :)
This is what I used

Code:
    # Redirect if www.example.com (case-insensitive) to example.com
    RewriteCond %{HTTP_HOST} ^www.yoursite\.com [NC]
    RewriteRule (.*) http://yoursite.com/$1 [R=301,L]
 

yavuz

Well-known member
#3
Neither of these worked for me. My .htaccess looks like this:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteRule f[\d]+/.+-([\d]+)/index([\d]+).html showthread.php?t=$1&page=$2 [NC,L]
    RewriteRule f[\d]+/.+-([\d]+)/ showthread.php?t=$1 [NC,L]
    RewriteRule f([\d]+)/index([\d]+).html forumdisplay.php?f=$1&page=$2 [NC,L]
    RewriteRule f([\d]+)/ forumdisplay.php?f=$1 [NC,L]
    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>
 

Carl

Well-known member
#4
Is this correct if the forum is in the forum subdirectory?

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mileskane\.org/forum$ [NC]
RewriteRule ^(.*)$ http://mileskane.org/forum/$1 [R=301,L]
 

Brogan

XenForo moderator
Staff member
#5
There's no need to specify the installation directory.
This is what I have in my root .htaccess, despite my forum being in the /community directory.

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

Carl

Well-known member
#6
There's no need to specify the installation directory.
This is what I have in my root .htaccess, despite my forum being in the /community directory.

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} www.example.com$
RewriteRule ^(.*)$ http://example.com$1 [R=301,L]
It wont work for me then - it redirects to my forum homepage (im wondering if the htaccess in my wordpress installation is affecting it.) :mad:
 

Lucas

Well-known member
#8
There's no need to specify the installation directory.
This is what I have in my root .htaccess, despite my forum being in the /community directory.

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} www.example.com$
RewriteRule ^(.*)$ http://example.com$1 [R=301,L]
This works for the root directory, but not if I access the forum as http://www.example.com/community, it'll still keep the www.
 

Kier

XenForo Developer
Staff member
#10
This is ours:
Code:
RewriteCond %{HTTP_HOST} !^xenforo\.com$
RewriteRule ^(.*)$ http://xenforo.com$1 [R=301,L]
 

Carl

Well-known member
#11
This is ours:
Code:
RewriteCond %{HTTP_HOST} !^xenforo\.com$
RewriteRule ^(.*)$ http://xenforo.com$1 [R=301,L]
Just gave that one a try Kier and it redirects to my wordpress homepage. :)

Is WordPress in the root?

Do you have any other rewrites in your root .htaccess?
Yes the wordpress installation is in the root

These are the contents of that .htaccess
Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
 

Brogan

XenForo moderator
Staff member
#13
Try removing the wordpress rewrites temporarily just to test which version of the non-www works.

Once you've determined which one works, you can then work on trying to integrate them.