Forum Moderators: phranque

Message Too Old, No Replies

How to avoid calling the site without www

for Both main domain and subdomain

         

anees_muhd

6:22 am on Feb 12, 2009 (gmt 0)

10+ Year Member



Hi

i have my main domain as
www.mysite.com

and i have a number of subdomains calls under the main site like www.dubai.mysite.com, www.tasmania.mysite.com

we are using wild card forwarding to manage all subdomains

So in all the above situations it redirects into the same directory.

the rules i have used before to redirect a site to www is

RewriteCond %{HTTP_HOST} ^mysite\.com
RewriteRule ^(.*)$ [mysite\.com...] [R=301,L]

and for subdomain sites

RewriteCond %{HTTP_HOST} ^^([^.]+)\.mysite\.com$ [NC]
RewriteRule ^(.*)$ [www\.%1\.mysite\.com...] [R=301,L]

Because it was calling two different directories, am able to write those rules in to different .htaccess files

But now i need to combine those two rules into one .htaccess file

Please help me to make it
[when i tried with my little knowledge it goes to www.www.mysite.com when i have given www.mysite.com]

Thanks in Advance
Anees

Wlauzon

8:42 am on Feb 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



..www.dubai.mysite.com, www.tasmania.mysite.com..

I did not think you have have the www with a subdomain?

anees_muhd

10:00 am on Feb 12, 2009 (gmt 0)

10+ Year Member



Hi,
Thanks for your reply

So your telling its not normal
that keeping www with subdomains?

jdMorgan

2:47 pm on Feb 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"www" is a subdomain. www.country.example.com is a sub-sub-domain.

The "usual" approach would be to redirect example.com to www.example.com, and redirect www.<country>.example.com or <country>.www. example.com to <country>.example.com:


# Externally redirect requests for "example.com" to "www.example.com"
RewriteCond %{HTTP_HOST} ^example\.com [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com\. [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com:
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
# Externally redirect requests for non-canonical subdomains to canonical subdomains
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.example\.com [OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.example\.com [OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com\. [OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com:
RewriteRule (.*) http://%1.example.com/$1 [R=301,L]

The additional checks for trailing dot and colon are to detect requests where the hostname includes a trailing period indicating a FQDN, or a colon followed by a port number. In both cases, the hostname is valid, but non-canonical. I also showed each case separately, just for clarity.

Jim

anees_muhd

5:07 am on Feb 13, 2009 (gmt 0)

10+ Year Member



Hi,
Thanks Jim for your reply

The sample you have given is pretty clear to follow. Thanks again

In My problem the Subdomains are already Up and running..
and having a lot of backlinks posted in sites as
www.<country>.example.com

Does this will cause any effect in search engines perspective?

Is there any issues if i go with the same approach that i have implemented now (eg.www.<country>.example.com)

Anees

jdMorgan

1:38 pm on Feb 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The main problem is extra typing, and a long URL that may be truncated in search results.

You have to decide between "what is now" and "what will be." If your site is relatively new and you plan to stay on-line for a long time, then I would recommend getting rid of the extra "www" sub-sub-domain to improve usability and make your URLs more "attractive" in search results.

Also, the longer a URL is, the harder it is to type, and the harder it is to read or to "hear" correctly. Imagine one friend trying to tell another about your site using a telephone. Imagine a news or television announcer reading your URL to listeners. And imagine another Webmaster trying to link to your site: The longer the URL, the more chances for errors -- and errors mean lost traffic and revenue.

The 301 redirects will "connect" the old www.country.example.com URLs to the new, shorter country.example.com URLs, and the old URLs' PageRank and link-popularity will be passed to the new URLs as well.

As with all imperfections, make your site as good as it can possibly be today, so that you don't have to deal with bigger problems in the future that result from small problems today. In today's economic climate, even a small issue may result in decreased revenue, and companies with decreased revenue tend to lay off workers. So even a minor thing like a missing trailing slash might eventually cost you your job!

Just my opinions, here... I like my sites to be "perfect." :)

Jim

anees_muhd

1:47 pm on Feb 13, 2009 (gmt 0)

10+ Year Member



Hi

Thanks Jim
Its really a good advice
Thanks very much

Anees