Forum Moderators: phranque
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
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]
Jim
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
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