问题
I know there's tons of docs on any one of these items, but I can't seem to find the .htaccess code to do all of them together.
Goal/requirements:
- No prefix domain.tld redirects to www.domain.tld
- Subdomain'd domain (ex. mail.domain.tld) still goes to mail.domain.tld, i.e. does not get redirected to www.domain.tld
- Domain.tld/subdirectory redirects to www.domain.tld/subdirectory.
NOTE: domains will vary, but subdirectory will always be the same, i.e. all domains have the subdirectory. For example, domain1.ca/sub -> www.domain1.ca/sub, www.domain2.com/sub -> www.domain2.com/sub, domain3.org/sub -> www.domain3.org/sub
So far I have:
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
... which satisfies (1) and (2). How do I bundle (3) in their? Thanks!
来源:https://stackoverflow.com/questions/31082504/htaccess-redirect-non-www-domains-including-subdirectoies-to-www-and-exclude-su