.htaccess - remove www. except when https

Reply

Join Date: Aug 2007
Posts: 11
Reputation: bigtalk is an unknown quantity at this point 
Solved Threads: 0
bigtalk's Avatar
bigtalk bigtalk is offline Offline
Newbie Poster

.htaccess - remove www. except when https

 
0
  #1
Apr 23rd, 2009
Hello,

I am trying to remove the www. at the beginning of our domain name via .htaccess. I'm doing it like this:
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R,NC]
It seems to word wonderfully.

I would like to retain the www. when someone accesses the site securely with https. I found a bit of code on the web that described how to force the www. except on a certain folder ("blog" in this case):
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule !^blog(/.*)?$ http://www.domain.com%{REQUEST_URI} [R,L]

I thought if I changed it a little, I could make at least a single folder keep the www. like this:
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule !^secure(/.*)?$ http://.domain.com%{REQUEST_URI} [R,L]

It didn't work. I got a redirect loop error.

Any ideas?
nerding-out hard core.

Check out my music at:
www.JonRyser.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Linux Servers and Apache Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC