.htaccess www to non-www redirect problem

I'm having a bit of trouble redirecting my site.

I have multi-site drupal installed in sub directories and I'm trying to redirect www to non-www if I type in www.colorgenetics.info it will redirect to the non-www site but If i type something like www.colorgenetics.info/feline itstead of redirecting to colorgenetics.info/feline it redirects to the base colorgenetics.info

If you go to lvl deeper such as colorgenetics.info/equine/forum it redirects to colorgenetics.info/forum

Even more confusing is the fact that if I go to www.colorgenetics.info/equine/gallery/v/dilutions it doesn't redirect at all but retains the www

This maybe a combination of issues since I have a gallery2 embeded in drupal and that may be causing some of the problems.

A sample of the gallery redirect rules

#equine gallery rewrite rules
     RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
    RewriteCond %{REQUEST_URI} !/equine/index\.php$
    RewriteRule .   -   [L]

    RewriteCond %{THE_REQUEST} /equine/d/([0-9]+)\-([0-9]+)/([^/?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/equine/index\.php$
    RewriteRule .   /equine_gallery/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3   [QSA,L]
    RewriteCond %{THE_REQUEST} /equine/gallery/v/([^?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/equine/index\.php$
    RewriteRule .   /equine/index.php?q=gallery&g2_path=%1   [QSA,L]

and the stuff that handles the sub-directories

#rewrite subdomains to subdirectories
#rewrite www to without www
    RewriteCond %{HTTP_HOST} ^www\.colorgenetics\.info$ [NC]
    RewriteRule ^(.*)$ http://colorgenetics.info/$1 [L,R=301]

#rewrite subdomains to subdirectories
     RewriteCond %{HTTP_HOST} ^feline\.colorgenetics\.info$ [NC]
    RewriteRule ^(.*)$ http://colorgenetics.info/feline/$1 [L,R=301]

 RewriteCond %{HTTP_HOST} ^canine\.colorgenetics\.info$ [NC]
    RewriteRule ^(.*)$ http://colorgenetics.info/canine/$1 [L,R=301]

 RewriteCond %{HTTP_HOST} ^equine\.colorgenetics\.info$ [NC]
    RewriteRule ^(.*)$ http://colorgenetics.info/equine/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/feline/(.*)$
RewriteRule ^(.*)$ /feline/index.php?q=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/canine/(.*)$
RewriteRule ^(.*)$ /canine/index.php?q=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/equine/(.*)$
RewriteRule ^(.*)$ /equine/index.php?q=$1 [L,QSA]

thanks for the help

2 Replies

I decided it would be better to post my entire .htaccess file. So here it is

http://pastebin.com/zvFaq1Gu

I'm trying my best to learn some of this stuff but most of it is still over my head. I hope I have everything in the right order. I have the boost rules first, 2nd the gallery ones, third the sub-domain rewrite rules, and then the drupal rules to write everything to index.php. I'm not sure exactly where in the scheme of things the sub-domain rewrite rules are supposed to go but I've tried moving them and it either broke the sub-domain rewrites or kept things the same.

I'm completely baffled as to why equine.colorgenetics.info/forum will redirect as it is supposed to to colorgenetics.info/equine/forum but www.colorgenetics.info/equine/forum redirects to colorgenetics.info/forum

I also tried adding

RewriteCond %{HTTP_HOST} ^www.colorgenetics.info\feline$ [NC]

RewriteRule ^(.*)$ http://colorgenetics.info/feline/$1 [L,R=301]

or

RewriteCond %{HTTP_HOST} ^www.colorgenetics.info/feline$ [NC]

RewriteRule ^(.*)$ http://colorgenetics.info/feline/$1 [L,R=301]

But neither of those did anything

for the moment I have removed the

RewriteCond %{HTTP_HOST} ^www.colorgenetics.info$ [NC]

RewriteRule ^(.*)$ http://colorgenetics.info/$1 [L,R=301]

from my .htaccess file. I would rather have a user access via the www sub-domain then be redirected to a url that doesn't exist.

I still don't understand why feline.colorgenetics.info/forum well be rerouted correctly to colorgenetics.info/feline/forum while www.colorgenetics.info/feline/forum will be rerouted to colorgenetics.info/forum

I still have boost disabled for the site.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct