0

I've set up an Apache rewrite rule to redirect all sites from one subdomain to another - one ruleset for each site:

<Directory /var/www/PATH_TO_WEBROOT_X>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^(.*)\.subdomainOLD\.com$ [NC]
    RewriteRule ^(.*)$ http://%1.subdomainNEW.com/$1 [L,R=301]
</Directory>

Also each site virtualhosts has the old and the new domains, eg:

<VirtualHost *:80>
    DocumentRoot "/var/www/PATH_TO_WEBROOT_X"
    ServerName foo.subdomainNEW.com
    ServerAlias foo.subdomainOLD.com foo.subdomainNEW.com
</VirtualHost>

This seems to work, except when it's a Drupal project (in case of Drupal it just stays on the old domain). I've googled it and the best I've found is the DomainDefaultRedirection (https://www.drupal.org/project/domain_default_redirect) module - however I would like to achieve it without changing the Drupal config.

Is it the Drupal .htaccess that conflicts with my rules or something else?

Update: the setup is fairly standard. Drupal is generic, core 7.x. Apache2.2. All sites are enabled through virtual hosts inside sites-enabled - one config file per site. Tried to put the redirect rule to a generic apache config as well as into the site specific virtual host. The directory is matched always against the targeted site directory.

  • 2
    I think this may be off-topic because it is about server configuration that happens before Drupal have a chance to execute anything. To tell if there is a conflict between Drupal .htaccess and rules in question, we would need significantly more data, like where are these rules, what is apache's configuration about htaccess files, and so on. – Mołot Jan 16 '15 at 10:16
  • Thanks @Mołot, updated the ticket. You're right, it's a server config issue. I thought however - because it happens only with Drupal, there is a Drupal-thing in it. – itarato Jan 16 '15 at 15:58
  • Drupal related server issues are on topic here. But we need to be able to tell if and how - the same information will also be needed to answer it, anyway, no matter what site it's asked on. – Mołot Jan 16 '15 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.