.htaccess htaccess重定向子域
我有以下.htaccess代码:.htaccess htaccess重定向子域,.htaccess,redirect,subdomain,.htaccess,Redirect,Subdomain,我有以下.htaccess代码: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} !^www.mysite.co$ [NC] RewriteRule ^(.*)$ http://www.mysite.co/$1 [R=301,QSA,L] </IfModule> 重新启动发动机 重写cond%{HTTP_HOST}^www.mysite.co$[NC] 重写规则^(.*)$htt
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.mysite.co$ [NC]
RewriteRule ^(.*)$ http://www.mysite.co/$1 [R=301,QSA,L]
</IfModule>
重新启动发动机
重写cond%{HTTP_HOST}^www.mysite.co$[NC]
重写规则^(.*)$http://www.mysite.co/$1[R=301,QSA,L]
问题是所有子域都被重定向到www.mysite.co/subdomain
我如何避免这种情况?简单地说,您的重写规则逻辑正在执行以下操作:
重新启动发动机
重写cond%{HTTP_HOST}^www.mysite.co$[NC]
重写cond%{HTTP_HOST}^blog.mysite.co$[NC]
重写cond%{HTTP_HOST}^foo.mysite.co$[NC]
重写规则^(.*)$http://www.mysite.co/$1[R=301,QSA,L]
您需要运行index.php文件
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+)\.example\.com$ [NC]
RewriteRule !^index\.php($|/) index.php/accounts/%2%{REQUEST_URI} [PT,L]
这似乎是根据重写的意图。您是否仅在有人访问
http://mysite.co/
?
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+)\.example\.com$ [NC]
RewriteRule !^index\.php($|/) index.php/accounts/%2%{REQUEST_URI} [PT,L]