Forum Moderators: DixonJones

Message Too Old, No Replies

can .htaccess do this?

many sub-domain names directed to just one

         

anchordesk

4:44 pm on Aug 20, 2003 (gmt 0)

10+ Year Member



I maintain a community based web site which serves a local (3 state area) sports club. It is hosted on my own domain as a sub-domain (e.g. [sportingnews.mydomain.com...] ). Since my host provider allows for unlimited sub-domains, over the years I have set up several sub-domains all pointing to the same root folder to allow for the various mis-spellings and nicknames users would attempt to use in accessing the site.

The site is easy to find via search engines, however, SE's have it listed by all the multipule sub-domain names. Furthermore, I've come to realize that each sub-domain name carries a different PageRank. I've assumed that SE's like Google would figure to index the site under only one domain name rather than all since it's all duplicate content. So far, no.

Can .htaccess be used in some manner to get all incomming users on to just the one main original sub-domain? Bookmarking would then be correct, SE's would index under the correct sub-domain name, etc ...

Thanks...anchordesk

jdMorgan

4:53 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



anchordesk,

Yes, you can use .htaccess to do a 301-Moved Permanently redirect from your various subdomains to any place you like. The regular expressions pattern matching used by RedirectMatch in mod_alias and native to mod_rewrite may come in very handy to allow you to redirect groups of subdomains to one destination. This avoids having to have a redirect for each and every one.

With mod_rewrite, you could even set it up so that it redirects all subdomains except the ones you want to keep separate, saving work and future-proofing your rewrite code.

Here's a good start: Introduction to mod_rewrite [webmasterworld.com]

Jim

anchordesk

2:45 pm on Aug 22, 2003 (gmt 0)

10+ Year Member



Thanks Jim -

Learning the abilities of htaccess has provided me with a sense of enjoyment once reserved for programming desktop applications. The depth of webmasterworld is refreshing.

-anchordesk