0

I'd like to use .htaccess to redirect any non-www domain to its www equivalent, regardless of directory - I assume I need multiple RewriteRules

Goal:

domain.tld -> www.domain.tld
www.domain.tld -> www.domain.tld
domain.tld/directory -> www.domain.tld/directory
www.domain.tld -> www.domain.tld/directory

So far I have

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

... but all that does is redirect domain.tld -> www.domain.tld. It does not account for a directory. That is, domain.tld/directory does not redirect to www.domain.tld/directory; it just goes directly to domain.tld/directory

Perhaps I need a separate rewrite rule? I'm cool with that.

Any help is greatly appreciated

user2961787
  • 41
  • 1
  • 8
  • This rule is fine. Do you have another .htaccess somewhere ? – anubhava Jun 30 '15 at 19:52
  • I do have another htaccess but it does not contain any redirects. Not a duplicate because that one asks for everything in one statement. I'm asking for one thing: domain.tld/dir -> www.domain.tld/dir – user2961787 Jul 01 '15 at 00:21

0 Answers0