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
.htaccess 将文件夹重写为子域_.htaccess_Rewrite_Subdomain_Subdirectory - Fatal编程技术网

.htaccess 将文件夹重写为子域

.htaccess 将文件夹重写为子域,.htaccess,rewrite,subdomain,subdirectory,.htaccess,Rewrite,Subdomain,Subdirectory,我想在此之后重写所有地址 http://www.mydomain.com/questions/* 对此 http://*.mydomain.com/ 例如: http://www.mydomain.com/questions/example http://example.mydomain.com/ 有人能帮我解决这个问题吗 谢谢你,好了 RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [OR] RewriteCond

我想在此之后重写所有地址
http://www.mydomain.com/questions/*

对此
http://*.mydomain.com/

例如:
http://www.mydomain.com/questions/example

http://example.mydomain.com/

有人能帮我解决这个问题吗
谢谢你,好了

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^.mydomain\.com$
RewriteRule ^questions/([^/]+)/?$ http://$1.mydomain.com/ [NC,R=301,L]

将此文件插入.htaccess文件,您就可以开始了。:)

第一条规则不是必需的,第二条规则应该是:
RewriteRule^questions/([^/]+)/?$http://$1.mydomain.com/[NC,R=301,L]
Hmm,我明白了。修改。谢谢,但不起作用!我还在我的webhost中启用了通配符子域,并在我的主机子域和域dns面板中添加了*.mydomain.com。你有什么建议吗!?是的,您需要再添加一行,以便为非www URL启用它。我对它进行了相应的编辑。让我知道它是否解决了问题。