Apache Mod_rewrite.htaccess子域,但区分干净子域和路径URL
我如何修改(in.htaccess)来实现这一点Apache Mod_rewrite.htaccess子域,但区分干净子域和路径URL,apache,.htaccess,mod-rewrite,wildcard,subdomain,Apache,.htaccess,Mod Rewrite,Wildcard,Subdomain,我如何修改(in.htaccess)来实现这一点 {subdomain}.thedomain.com 或 。。。。。。应改写为: thedomain.com/index.php?do={subdomain} 。。。。但是,所有其他文件或目录都应该在没有子域部分的情况下重写,其余部分保持原样。 e、 g xyz.thedomain.com/something/somethingelse/somefile.jpg -----------> 只要您的子域指向与主域相同的文档根,您所需要做的就是
{subdomain}.thedomain.com
或
。。。。。。应改写为:
thedomain.com/index.php?do={subdomain}
。。。。但是,所有其他文件或目录都应该在没有子域部分的情况下重写,其余部分保持原样。
e、 g
xyz.thedomain.com/something/somethingelse/somefile.jpg
----------->
只要您的子域指向与主域相同的文档根,您所需要做的就是将这些规则添加到文档根中的htaccess文件中
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.thedomain\.com$ [NC]
RewriteRule ^(.+)$ http://thedomain.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.thedomain\.com$ [NC]
RewriteRule ^/?$ /index.php?do=%1 [L]
thedomain.com/something/somethingelse/somefile.jpg
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.thedomain\.com$ [NC]
RewriteRule ^(.+)$ http://thedomain.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.thedomain\.com$ [NC]
RewriteRule ^/?$ /index.php?do=%1 [L]