htaccess的重定向从子目录根 [英] Htaccess Redirect from subdirectory to root

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

问题描述

我在寻找一个htaccess的code重定向我的网址是这样的:

I'm looking for a htaccess code to redirect my url's like this :

http://01.mydomain.com/subdir/xyz [OR]
http://www.01.mydomain.com/subdir/xyz [OR]
http://02.mydomain.com/subdir/xyz [OR]
http://www.02.mydomain.com/subdir/xyz
TO : http://www .mydomain.com/xyz

和在这种情况下 XYZ 是动态的,可以是任何值。和子目录是不变的

and in this case xyz is dynamic and could be any value. and subdir is constant

推荐答案

假设子目录是恒定的,下面是一个方法:

Assuming subdir is constant, the following is one way:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^01.mydomain.com [OR]
RewriteCond %{HTTP_HOST} ^www.01.mydomain.com [OR]
RewriteCond %{HTTP_HOST} ^02.mydomain.com [OR]
RewriteCond %{HTTP_HOST} ^www.02.mydomain.com
RewriteRule ^subdir/(.*)$ http://www.mydomain.com/$1 [L,R=301]

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

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