0

Stock Drupal 7 contains the following in the .htaccess file

  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # uncomment the following:
  RewriteCond %{HTTP_HOST} .
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

As per client request, this works just dandy! However, on a multisite installation, one site wants to be excluded from this rule. I tried to get them to remove the auto-www-append, but alas, that failed.

So now I'm in a situation which some multisites (most of them) want the www appended and a small group doesn't want it.

My question: Can I exempt some sites from this rule? Can I throw these exceptions into an apache conf file in /etc/httpd/conf.d/www-exceptions.cnf so that it's not overwritten in a core update?

1 Answer 1

0

Unfortunately putting separate htaccess files in each sites folder doesnt work, otherwise it would be quite straight forward.

Perhaps you can use REWRITECOND to do this?

RewriteCond %{REQUEST_URI} yourclientsdomain.com
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

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.