Hi All,

It seems that if users enter my site without the www. in the webdomain that certain JS libs don't load correctly in CiviCRM.

My first thought was to use directives in the HTACCESS file to redirect but I'm not sure if this will mess up drupal...

something like this

#Redirect to www location
RewriteEngine on
RewriteBase /
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

Is there a better way to do this? perhaps its already built in?

Comments

Anonymous’s picture

It's already built in. From the default .htaccess file:

# (http://example.com/... will be redirected to http://www.example.com/...)
# uncomment the following:
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment the following:
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
nvisioncurtis’s picture

I also would like to redirect an alias domain to the real domain. I didn't see any code in there for that specifically.

I think this might work

RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

Would cause a circular loop?