htaccess的重定向到子域,并保持串 [英] htaccess redirect to subdomain and keep string

查看:180
本文介绍了htaccess的重定向到子域,并保持串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我试图实现是这样的:

我最近搬到我的网站的一部分,一个子域不同的服务器上,以便曾经被认为是在: http://mysite.com/clients 现在上 http://clients.mysite.com

使用: RedirectMatch 301 HTTPS:(。*)//mysite.com/clients/^ $ https://clients.mysite.com/$1 工作正常对于简单地将人打 http://mysite.com/clients 新的子域名,但是我希望能够preserve后弦/客户机/

因此​​,如果有人例如打 http://mysite.com/clients/could_be_a_number_of_things.php 重定向到 http://clients.mysite.com/could_be_a_number_of_things.php

谁能指教?

根据要求全面的.htaccess:

 #-FrontPage-

IndexIgnore的.htaccess * /。?? *〜*#* / HEADER * * / README * * / _ VTI *

<限制GET POST>
为了否认,允许
所有否认
允许所有
< /限制>
<限制PUT DELETE>
为了否认,允许
所有否认
< /限制>
#AuthName mysite.com
#AuthUserFile /home/inhost/public_html/_vti_pvt/service.pwd
#AuthGroupFile /home/inhost/public_html/_vti_pvt/service.grp

#BEGIN字preSS
选项​​+的FollowSymLinks -MultiViews
< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteBase /
重写规则^指数\ .PHP $  -  [L]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。的index.php [L]
的RewriteCond%{} HTTPS S上(S)|
的RewriteCond%{HTTP_HOST} ^(WWW \)?mysite的\ .COM $
重写规则^客户/(.*)$ HTTP%1://clients.mysite.com/$1 [L,NC,R = 301]
< / IfModule>

#结束字preSS
 

解决方案

的httpd.conf 启用了mod_rewrite和.htaccess,然后把这个code在< $ C C>的.htaccess $ DOCUMENT_ROOT 目录下的 mysite.com 服务器上:

 选项+了FollowSymLinks -MultiViews
#开启mod_rewrite的上
RewriteEngine叙述上
的RewriteBase /

的RewriteCond%{} HTTPS S上(S)|
的RewriteCond%{HTTP_HOST} ^(WWW \)?mysite的\ .COM $
重写规则^客户/(.*)$ HTTP%1://clients.mysite.com/$1 [L,NC,R = 301]
 

Found a few similar questions but either I cant figure it out from the answers or they dont directly match my needs.

What I am trying to achieve is this:

I recently moved part of my site to a sub domain on a different server so what used to be in: http://mysite.com/clients is now on http://clients.mysite.com

using: RedirectMatch 301 https?://mysite.com/clients/^(.*)$ https://clients.mysite.com/$1 works fine for simply redirecting people hitting http://mysite.com/clients to the new sub domain however I would like to be able to preserve the string after /clients/

so if someone hits e.g. http://mysite.com/clients/could_be_a_number_of_things.php it redirects to http://clients.mysite.com/could_be_a_number_of_things.php

Can anyone advise?

full .htaccess as requested:

    # -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

解决方案

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory on mysite.com server:

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]

这篇关于htaccess的重定向到子域,并保持串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆