用httpd.ini成功二级域名跳转子目录的方法
作者:我就是个世界
发表于:2012-09-25
[b]目的:[/b]把 a.st-winthink.com 跳转到 www.st-winthink.com/a
[b]环境:[/b]win主机虚拟空间/或已安装伪静态(ISAPI_Rewrite)的独立主机或VPS
[b]配置:[/b]网站根目录新建httpd.ini URL重定向文件
[b]代码:[/b][separator]
[code]
[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]
[/code]
第一部分是加入的跳转代码,可以实现
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
第二部分是程序主网站自身的伪静态代码
这样可以实现各种跳转,大家可以亲自测试,保证是成功跳转的!
[b]环境:[/b]win主机虚拟空间/或已安装伪静态(ISAPI_Rewrite)的独立主机或VPS
[b]配置:[/b]网站根目录新建httpd.ini URL重定向文件
[b]代码:[/b][separator]
[code]
[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]
[/code]
第一部分是加入的跳转代码,可以实现
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
第二部分是程序主网站自身的伪静态代码
这样可以实现各种跳转,大家可以亲自测试,保证是成功跳转的!
请发表您的评论