あなたの.htaccessはdomain.comをwww.domain.comにリダイレクトするが、sub.domain.comは変更しないでください。
ここに
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
converts domain.com to www.domain.com but also converts
sub.domain.com to www.domain.com/subdomains/sub(wここに it’s contents
are). I want sub.domain.com to remain in the browser window while
the contents of www.domain.com/subdomains/sub are shown(as
usual).
あなたのルールは、 www.domain.com
ではないすべてのドメインに対して実行されています。代わりに、HTTP_HOSTが次のようにできる `domain.com ‘
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
In regular expressions, ^
denotes the start of the
string and $
denotes the end of the string and
!
at the beginning means match everything that is not
the following. That’s going to catch all domains that are not
exactly www.domain.com. In my example, I am only matching domains
that are exactly domain.com
and redirecting it to
www.domain.com
私は通常、私のvhostファイルでそれを行います。
ServerName domain.com
Redirect permanent/http://www.domain.com/
CustomLog logs/domain.com/access_log combined
ErrorLog logs/domin.com/error_log
DocumentRoot /var/www/domain.com
ServerName www.domain.com
ServerAdmin [email protected]
CustomLog logs/domain.com/access_log combined
ErrorLog logs/domain.com/error_log
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all