-1

For our shop CMS we have a system that works like this:

When a customer registers they will get a subdomain on our root domain.

Something like: myshop.daretoshop.nl

For SEO we want the users to be redirected to the non www version of this subdomain when they enter www.myshop.daretoshop.nl, so they are redirected (301) to myshop.daretoshop.nl

Is this possible with htaccess? We want this so happend with all subdomains, so maybe its possible to set this globally?

thanks in advance.

1 Answers1

0

Use mod_rewrite.

For mod_rewrite directives to work using .htaccess, you need to set AllowOverride FileInfo. Details about how to configure mod_rewrite for your specific needs can be found in one of the similar questions, such as Generic htaccess redirect www to non-www.

You also need to configure your DNS server such that the subdomains are actually resolved to the IP address of your web server.

BTW there are absolutely no SEO benefits in redirecting http://www.example.com to http://example.com.

Community
  • 1
  • 1
Oswald
  • 31,254
  • 3
  • 43
  • 68