htaccessredirect到子域并保持string

发现了一些类似的问题,但是我不能从答案中找出答案,或者他们不直接匹配我的需求。

我想实现的是这样的:

我最近将部分网站移到了另一台服务器上的子域,所以曾经是: http://mysite.com/clientshttp://mysite.com/clients现在在http://clients.mysite.com

使用: RedirectMatch 301 https?://mysite.com/clients/^(.*)$ https://clients.mysite.com/$1工作正常,只需redirecthttp://mysite.com/clients打到新的子域,但是我希望能够保存string/客户端/

所以如果有人点击,例如http://mysite.com/clients/could_be_a_number_of_things.php它redirect到http://clients.mysite.com/could_be_a_number_of_things.php

任何人都可以build议吗?

完整的.htaccess按要求:

  # -FrontPage- IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* <Limit GET POST> order deny,allow deny from all allow from all </Limit> <Limit PUT DELETE> order deny,allow deny from all </Limit> #AuthName mysite.com #AuthUserFile /home/inhost/public_html/_vti_pvt/service.pwd #AuthGroupFile /home/inhost/public_html/_vti_pvt/service.grp # BEGIN WordPress Options +FollowSymLinks -MultiViews <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteCond %{HTTPS}s on(s)| RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$ RewriteRule ^clients/(.*)$ http%1://clients.mysite.com/$1 [L,NC,R=301] </IfModule> # END WordPress 

通过httpd.conf启用mod_rewrite和.htaccess,然后把这个代码放在mysite.com服务器上DOCUMENT_ROOT目录下的.htaccess

 Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{HTTPS}s on(s)| RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$ RewriteRule ^clients/(.*)$ http%1://clients.mysite.com/$1 [L,NC,R=301]