Tricky www on multi-subdomains

Using a single web hosting account to host multiple sites

Tricky www on multi-subdomains

Postby mikeall » Fri Oct 27, 2006 5:45 pm

Hi (first post here)

I have a client who needs to have many domains running from the same CMS (Joomla). I want to be able to force www.domain.com or www.domain.com.au but not if it is forum.domain.com or forum.domain.com.au etc.

I need to have it work on both http and https URLs.

This is something I have currently but it puts www on front of all subs-domains.
Code: Select all
RewriteEngine On

RewriteCond %{REQUEST_URI}\\/%{HTTP_HOST}/www.//s%{HTTPS} ^/+(.+/)?[^.]*[^/]\\(/)([^w][^w][^w][^.].*/(www\.)|.*)//((s)on|s.*)$ [OR,NC]
RewriteCond %{HTTP_HOST}/www.//s%{HTTPS} ^(/)?(/)?([^w][^w][^w][^.].*/(www\.))//((s)on|s.*)$ [NC]
RewriteRule ^ http%6://%4%{HTTP_HOST}%{REQUEST_URI}%2 [L,R=301]


Having spent many hours looking for a solution (and not finding one) I thought I should ask you experts.

Any pointers would be greatly appreciated.
mikeall
 
Posts: 4
Joined: Fri Oct 27, 2006 5:22 pm
Location: Melbourne, Australia

Postby richardk » Sat Oct 28, 2006 7:00 am

Maybe:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond s%{HTTPS}::%{HTTP_HOST} ^((s)on|s.*)::([^\.]+\.)(com(\.au)?)$ [NC]
RewriteRule ^(.*)$ http%2://www.%3%4/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby mikeall » Sat Oct 28, 2006 2:15 pm

Ok thanks - I'll try it and report back.
mikeall
 
Posts: 4
Joined: Fri Oct 27, 2006 5:22 pm
Location: Melbourne, Australia

force non use of www?

Postby mikeall » Thu Nov 23, 2006 8:52 pm

Since some of the domains are long, I have decided to use the non www option.

So that I don't have to adjust the htacess file each time I add a new domain, what can I write instead of:

Code: Select all
RewriteCond %{HTTP_HOST} ^www\.tom\.com$ [NC]?RewriteRule ^(.*)$ http://tom.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.jerry\.com$ [NC]?RewriteRule ^(.*)$ http://jerry.com/$1 [L,R=301]
mikeall
 
Posts: 4
Joined: Fri Oct 27, 2006 5:22 pm
Location: Melbourne, Australia

Postby richardk » Fri Nov 24, 2006 10:33 am

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond s%{HTTPS}::%{HTTP_HOST} ^((s)on|s.*)::www\.([^\.]+\.com(\.au)?)$ [NC]
RewriteRule ^(.*)$ http%2://%3/$1 [R=301,L]


Or
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.([^\.]+\.[^\.]+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 25 guests

cron