内容正在载入中,请稍后……
公告
About me
搜索
统计
其他
25 Sep.2012

用httpd.ini成功二级域名跳转子目录的方法 不指定

作者: 我就是个世界   分类:技术&学习 » 服务器环境   出处:本站原创            | |
目的:把 a.st-winthink.com  跳转到 www.st-winthink.com/a  
环境:win主机虚拟空间/或已安装伪静态(ISAPI_Rewrite)的独立主机或VPS
配置:网站根目录新建httpd.ini URL重定向文件
代码:

[ISAPI_Rewrite]

CacheClockRate 3600
RepeatLimit 32

#Redirect to www.st-winthink.com
RewriteCond Host: ^st-winthink\.com$
RewriteRule (.*) http\://www\.st-winthink\.com [R,I]

RewriteCond Host: ^a\.st-winthink\.com$
RewriteRule (.*) http\://www\.st-winthink\.com/a$1 [I,R]
RewriteCond Host: ^b\.st-winthink\.com$
RewriteRule (.*) http\://www\.st-winthink\.com/a/index.php\?homepage=b [I,R]

#Other RewriteRule
RewriteRule ^(.*)/libs/(.*)\.html                           $1/libs/$2\.html [L]
RewriteRule ^(.*)/index\.html$                              $1/index\.php [L]
RewriteRule ^(.*)/index-([a-z0-9])\.html$                   $1/index\.php\?langid=$2 [L]
RewriteRule ^(.*)/cid-([0-9]+)\.html$                       $1/index\.php\?c=list&cid=$2 [L]
RewriteRule ^(.*)/cid-([0-9]+)-([0-9]+)\.html$              $1/index\.php\?c=list&cid=$2&pageid=$3 [L]
RewriteRule ^(.*)/cs-([a-z0-9A-Z\_]+)\.html$                $1/index\.php\?c=list&cs=$2 [L]
RewriteRule ^(.*)/cs-([a-z0-9A-Z\_]+)-([0-9]+)\.html$       $1/index\.php\?c=list&cs=$2&pageid=$3 [L]
RewriteRule ^(.*)/mid-([0-9]+)\.html$                       $1/index\.php\?c=list&mid=$2 [L]
RewriteRule ^(.*)/mid-([0-9]+)-([0-9]+)\.html$              $1/index\.php\?c=list&mid=$2&pageid=$3 [L]
RewriteRule ^(.*)/ms-([a-z0-9A-Z\_]+)\.html$                $1/index\.php\?c=list&ms=$2 [L]
RewriteRule ^(.*)/ms-([a-z0-9A-Z\_]+)-([0-9]+)\.html$       $1/index\.php\?c=list&ms=$2&pageid=$3 [L]
RewriteRule ^(.*)/c([0-9]+)\.html$                          $1/index\.php\?c=msg&id=$2 [L]
RewriteRule ^(.*)/([a-z0-9A-Z\_]+)-([0-9]+)\.html$          $1/index\.php\?c=msg&ts=$2&pageid=$3 [L]
RewriteRule ^(.*)/([a-z0-9A-Z\_\-]+)\.html$                 $1/index\.php\?c=msg&ts=$2 [L]


第一部分是加入的跳转代码,可以实现
st-winthink.com 跳 www.st-winthink.com
a.st-winthink.com 跳 www.st-winthink.com/a
b.st-winthink.com 跳 http://www.st-winthink.com/a/index.php?homepage=b

第二部分是程序主网站自身的伪静态代码

这样可以实现各种跳转,大家可以亲自测试,保证是成功跳转的! 分享到QQ空间
发表评论
  昵称 [注册]
  密码 (游客无需密码)
  网址
  电邮
OpenID登入 权限选项 表情