使用htaccess的子域目录重定向
我想重定向这样的事情
sub-domain.domain.com/directory到domain.com/directory~~V
sub-domain.domain.com/directory to domain.com/directory
我试过重定向301 / domain.com/directory [htaccess的放置在子域文件]它工作正常子域名,但不会为子域内的目录工作。
I tried Redirect 301 / domain.com/directory [htaccess file placed in sub-domain] it works fine for the sub-domain but won't work for the directory within the sub-domain.
有人能帮我什么应该是.htaccess文件的内容?
Can somebody help me with what should be the content of .htaccess file ?
感谢。
如果您只是想从xxx.domain.com/yyy重新定向所有的请求www.domain.com/yyy~~V你可以使用:
If you simply want to re-direct all requests from xxx.domain.com/yyy to www.domain.com/yyy you can use:
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.domain/com/$1 [L,R]
注意:您需要确保重写引擎是第一次,等
NB: You'll need to ensure that the rewrite engine is on first, etc.
更新..
如果你只是想要一个301,在最后一行更改[L,R] [L,R = 301]
If you just want a 301, change the [L,R] on the last line to [L,R=301]