Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache Mod_rewrite.htaccess子域,但区分干净子域和路径URL_Apache_.htaccess_Mod Rewrite_Wildcard_Subdomain - Fatal编程技术网

Apache Mod_rewrite.htaccess子域,但区分干净子域和路径URL

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 -----------> 只要您的子域指向与主域相同的文档根,您所需要做的就是

我如何修改(in.htaccess)来实现这一点

{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]