Support ⇒ Explain Please ⇒ How to redirect www.domain.com to domain.com? ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum IndexExplain Please

How to redirect www.domain.com to domain.com? This topic is locked: you cannot edit posts or make replies.


I tried to redirect any requests from www.domain.com to domain.com by adding following rewrite rules to the .htaccess under site root:

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

But I am receiving a recursion error from apache. Can anyone please tell me the correct way to configure the .htaccess?

Cheers,

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2003 / 2.4.3/ 5.5.27/ 5.4.7 / 9.3.4.1


add to .htaccess


Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} www\.domain\.com$ [NC] RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

Double check you may only need to add the last 2 lines, check to see if the first 2 already exist.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Multiple Setups


I added the code you provide after line 67 (without the second line). But the redirect doesn't work.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2003 / 2.4.3/ 5.5.27/ 5.4.7 / 9.3.4.1


around line 33-35

should look like this

# if you use LEO, mod_rewrite is necessary <IfModule mod_rewrite.c> RewriteEngine On Options +FollowSymlinks rewritecond %{http_host} ^www.dizwebdesign.com [nc] rewriterule ^(.*)$ http://dizwebdesign.com/$1 [r=301,nc]

make sure you replace dizwebdesign with your domain name

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Multiple Setups


It works! Thank yo very much.

BTW, I just saw the the .htaccess is blocking baidu agent. Will that prevent Baidu from picking up my sites? My site is located in China. So I'd like Baidu to pick up my site. What should I do?

Cheers,

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2003 / 2.4.3/ 5.5.27/ 5.4.7 / 9.3.4.1


remove the block if you want it to access your site, but keep in mind it is blocked for a reason Wink

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Multiple Setups


Thanks. I notice that after adding the redirect code, I'm getting following error messages in apache log:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2003 / 2.4.3/ 5.5.27/ 5.4.7 / 9.3.4.1


that one would be out of my ability. I would try researching it on bing or google. I just checked my logs and Im not getting that error. Have you made any other changes to htaccess?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Multiple Setups


The only I did were:

1. Added
Options +FollowSymlinks rewritecond %{http_host} ^www.espc.asia [nc] rewriterule ^(.*)$ http://espc.asia/$1 [r=301,nc]

2. Deleted

RewriteCond %{HTTP_USER_AGENT} Baidu [NC,OR]

3. Changed

RewriteCond %{REQUEST_FILENAME} -f [NC,OR]

to:

RewriteCond %{REQUEST_FILENAME} [NC,OR]

because it is complaining following error:

RewriteCond: NoCase option for non-regex pattern '-f' is not supported and will be ignored.

which makes the log size growing rapidly.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2003 / 2.4.3/ 5.5.27/ 5.4.7 / 9.3.4.1


RewriteCond %{REQUEST_FILENAME} -f [OR]

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


I've replaced the redirect code provided by Diz with the one I posted in the first post, which I get form no-www.org. Now the recursion error is gone.

But there is another error in the apache log which I think is also related to .htaccess:

[Thu May 02 13:56:50 2013] [error] [client 120.32.110.243] File does not exist: D:/Server/Apache2.2/htdocs/espc/Your_Account, referer: http://espc.asia/Your_Account/error=2.html

It seems that whenever a visitor visits a page, it returns a similar error like this. e.g.:

D:/Server/Apache2.2/htdocs/espc/themes/reDesigned/chinese_simplified, referer: http://espc.asia/Competition/players.html [Thu May 02 14:09:36 2013] [error] [client 120.32.110.243] File does not exist: D:/Server/Apache2.2/htdocs/espc/Content, referer: http://espc.asia/Content/admin.html

My site has LEO enabled. It seems that these pages are assuming there is a folder on the server for each LEO generated directory.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2003 / 2.4.3/ 5.5.27/ 5.4.7 / 9.3.4.1


It seems it's not related to the root .htaccess. I reverted it to the default. But the above errors remain.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2003 / 2.4.3/ 5.5.27/ 5.4.7 / 9.3.4.1


well if you look at the error messeges

does not exist :
D:/Server/Apache2.2/htdocs/espc/Your_Account
D:/Server/Apache2.2/htdocs/espc/Content

espc being your root directory
your_account and Content being modules

should be

espc/modules/your_account and Content

sounds like a setting is wrong somewhere, make sure you Site path is correct in Admin/System/Main Settings/

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Multiple Setups


The site path use is /, is it correct?

Edit: I changed the site path to espc. Then I lost all css styles. I think my setting is correct.

Also, I use a working copy of my svn repos to serve the live site. Since there is a folder named .svn, which starts with a dot just like .htaccess, could this be a possible cause?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2003 / 2.4.3/ 5.5.27/ 5.4.7 / 9.3.4.1


you missing the / at the end

espc.asia/Content with out the "/" gives error

espc.asia/Content/ with "/" renders a page

same problem with both "missing files"

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Multiple Setups

All times are UTC
Post new topic This topic is locked: you cannot edit posts or make replies. Forum IndexExplain Please
Page 1 of 2


Jump to: