I've got a multi-site Drupal installation with 2 sub-domains pointing to the same Drupal site. Eg: subdomain1.mysite.com and subdomain2.mysite.com

I have a page set up using hook_menu with the path 'site/%'. Eg: subdomain1.mysite.com/site/test

I want all requests to subdomain2.mysite.com/% to point to this page. Eg: subdomain2.mysite.com/test should point to the same page as subdomain1.mysite.com/site/test

How can I do this?

1 Answer 1


Redirecting to a different domain

Redirect URLs From Old To New Domain Using 301 Redirects In .htaccess

When you need to switch a website from an old domain to a new domain, you need to redirect all your page URLs, this is when htaccess is your friend.

The code below will create 301 url redirects for both the www and non-www version of ‘olddomain.com‘ to the new domain ‘newdomain.com‘.

Add this .htaccess file to the OLD site webroot and upload the files from the old site to the new to see a seamless switch from an old domain to a new one.

So the example below is redirecting all URLs from olddomain.com to newdomain.com

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.olddomain\.com$
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^olddomain\.com$
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

You can also apply this to a subdomain – so the example below is redirecting all URLs from subdomain.olddomain.com to subdomain.newdomain.com

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain.olddomain.com$ 
RewriteRule ^(.*)$ http://subdomain.newdomain.com/$1 [R=301,L] 
RewriteCond %{HTTP_HOST} ^www.subdomain.olddomain.com$ 
RewriteRule ^(.*)$ http://subdomain.newdomain.com/$1 [R=301,L]

For more details

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.