Redirecting www to non-www

Carl

Well-known member
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 :)
 
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]
 
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>
 
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]
 
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]
 
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:
 
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
 
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.
 
Top Bottom