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 子域重写不起作用_Apache_.htaccess_Rewrite_Subdomain - Fatal编程技术网

Apache 子域重写不起作用

Apache 子域重写不起作用,apache,.htaccess,rewrite,subdomain,Apache,.htaccess,Rewrite,Subdomain,我正在尝试使用.htaccess文件为apache重写子域 目前: domain.com/subdomain 预期结果: subdomain.domain.com 这就是我目前所拥有的 RewriteEngine on RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC] RewriteRule ^subdomain/(.*)$ http://www.domain.

我正在尝试使用.htaccess文件为apache重写子域

目前: domain.com/subdomain

预期结果: subdomain.domain.com

这就是我目前所拥有的

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC]
RewriteRule ^subdomain/(.*)$ http://www.domain.com/$1 [R=301,L]
任何帮助都将不胜感激

干杯, 韦恩

试试这个:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^subdomain\. [NC]
RewriteRule . - [S=2]

RewriteRule ^subdomain/(.+)$ http://subdomain.domain.com/$1 [R=301,L]
RewriteRule ^subdomain/?$ http://subdomain.domain.com [R=301,L]

谢谢你的回复。不幸的是,这从来没有奏效。我有子域设置重定向到domain.com/directory(directory=子域指向的位置)。这是在cPanel中创建的。那里会不会有冲突?我发现了问题所在。显然,我把它设置为重定向,应该让它单独运行。所以它跳转到子目录,而不是它自己的子域。不好意思,我知道,谢谢你的帮助,贾斯汀!