如何使用htaccess重定向到子域

时间:2013-11-30 21:37:47

标签: apache .htaccess mod-rewrite

我想使用.htaccess在网站上使用子域名,但几乎没有使用.htaccess的经验。我在.htaccess文件中有以下内容,但它不起作用: 我大部分都是从其他人的建议中抄袭的。我想要的是进入 Family.mysitehere.org 并将其转到 mysitehere.org/Family 谁能告诉我这段代码有什么问题?非常感谢提前。

DirectoryIndex index.html index.htm index.php

AddHandler cgi-script .cgi .pl

Options +FollowSymLinks

RewriteEngine On

RewriteBase /

RewriteRule wmail$ http://webmail.x7hosting.com [R,NC]

RewriteCond %{HTTP_HOST} \.

RewriteCond %{HTTP_HOST} !^www\. [NC]

RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.mysitehere\.org(:80)?<>/([^/]*) [NC]

RewriteCond %1<>%3 !^(.*)<>\1$ [NC]

RewriteRule ^(.*) /%1/$1 [L]

ErrorDocument 404 /404missing.php

1 个答案:

答案 0 :(得分:0)

  

What I want is to enter Family.mysitehere.org and have it go to mysitehere.org/Family

DOCUMENT_ROOT/.htaccess文件中使用此代码:

RewriteEngine On

#RewriteCond %{HTTP_HOST} ^(Family)\.(mysitehere\.org)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]