D7 Fancy domain redirect and multisite

afbeelding van Developmentteam

When you own many domains for the same site you need some fancy redirecting when you want the user and Google to consider them as one and the same domain.

Example. It is quite common to have the .com, .eu, .net and .nl point to one and the same site.

 

 


This is in the apache vhost section

ServerName nonexistingservername.nl
ServerAlias *.example.nl *.example-xl.nl example-xl.com *.example-xl.com *.examplexl.eu *.examplexl.be
ServerAlias *.e-examplexl.nl *.e-example-xl.nl
RedirectMatch 301 (.*) http://examplexl.nl$1


DocumentRoot "/home/html/example"
ServerName examplexl.nl

  • The first block redirects all server aliases to the examplexl.nl domain.
  • The second block catches this domain and leads it to the document root.
  • In sites/examplexl.nl there is a settings.php which then sets the database for this multisite set of domains.
shadow