IXWebhosting上设置.htaccess实现discuz、wordpress二级域名映射子目录

昨天又一次去搞这棘手的.htaccess,郁闷的是Win7的ftp貌似不显示隐藏的.htaccess文件,基本上是用ftp命令行和boom管理系统操作的。众所周知ixwebhosting很贱,一个独立ip只能绑定一个域名,又做了全局的rewrite设置,导致通常的.htaccess都不好实现。半夜捣鼓半天,找到一个基本还行的写法

RewriteEngine   On
RewriteBase /

RewriteCond %{HTTP_HOST} ^bbs.gmsj.org$
RewriteCond %{REQUEST_URI} !^/bbs/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /bbs/$1
RewriteCond %{HTTP_HOST} ^bbs.gmsj.org$
RewriteRule ^(/)?$ /bbs/index.php [L]

RewriteCond %{HTTP_HOST} ^blog.gmsj.org$
RewriteCond %{REQUEST_URI} !^/blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /blog/$1
RewriteCond %{HTTP_HOST} ^blog.gmsj.org$
RewriteRule ^(/)?$ /blog/index.php [L]

RewriteCond %{HTTP_HOST} ^chd.gmsj.org$
RewriteCond %{REQUEST_URI} !^/chd/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /chd/$1 [L]
RewriteCond %{HTTP_HOST} ^chd.gmsj.org$
RewriteRule ^(/)?$ /chd/index.php [L]

这样写目前基本能满足要求了,bbs.gmsj.org可以访问gmsj.org/bbs,blog.gmsj.org可以访问gmsj.org/blog,只剩下一个bug,就是bbs.gmsj.org/index.php访问的是/index.php而bbs.gmsj.org/能正常访问gmsj.org/bbs/index.php,还有待继续探讨。正则表达式貌似在这个rewrite语法中不是完全一致。。

另外还有个问题就是wordpress,wordpress本身有rewrite设置,经测试,如果让wp自己设置.htaccess并不能很好满足我们的要求,需手动按下面操作进行。

在wp后台设置wordpress address和site addresss均为http://lxf.me,但/blog目录中的.htaccess不按默认生成的,而是稍作修改改为以下内容

# BEGIN WordPress

RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

# END WordPress

这样既可即使http://lxf.me/XXX能正确访问,又能使wp上出现的链接是blog.gmsj.org而不是gmsj.org/blog

以上内容仅供大家参考,我个人觉得设置这伪静态实在是个让人抓狂的事情。。

CategoriesUncategorized

3 Replies to “IXWebhosting上设置.htaccess实现discuz、wordpress二级域名映射子目录”

  1. 帮我看看如何修改。我不懂,感激不尽!!!
    我的邮箱ask.web@qq.com

    IXWebhosting安装shopnc伪静态.htaccess急!!求助!!
    # 将 RewriteEngine 模式打开
    RewriteEngine On

    # 修改以下语句中的 /shopnc 为你的商城目录地址,如果程序放在根目录中,请将 /shopnc 修改为 /
    RewriteBase /shopnc

    # Rewrite 系统规则请勿修改
    RewriteRule ^goods-([0-9]+).html$ index.php?act=goods&goods_id=$1
    RewriteRule ^groupbuy-([0-9]+).html$ index.php?act=groupbuy&group_id=$1
    RewriteRule ^article-([0-9]+).html$ index.php?act=article&article_id=$1
    RewriteRule ^goods_class_nav-([0-9]+).html$ index.php?act=goods_class&nav_id=$1
    RewriteRule ^goods_class_brand-([0-9]+).html$ index.php?act=goods_class&brand=$1
    RewriteRule ^goods_class-([0-9]+).html$ index.php?act=goods_class&cate_id=$1
    RewriteRule ^store-([0-9]+).html$ index.php?act=show_store&id=$1
    RewriteRule ^goods_class_nav_cate-([0-9]+)-([0-9]+).html$ index.php?act=goods_class&nav_id=$1&cate_id=$2
    RewriteRule ^activity-([0-9]+)-([0-9]*).html$ index.php?act=activity&activity_id=$1&nav_id=$2
    RewriteRule ^goods_class.html$ index.php?act=goods_class
    RewriteRule ^article_ac-([0-9]+)-([0-9]*).html$ index.php?act=article&ac_id=$1&nav_id=$2
    RewriteRule ^store_class-([0-9]+).html$ index.php?act=store_class&cate_id=$1
    RewriteRule ^store_credit_eval-([0-9]+)-([0-9]+).html$ index.php?act=show_store&op=credit&id=$1&eval=$2
    RewriteRule ^goods_info-([0-9]+).html$ index.php?act=goods&goods_id=$1
    RewriteRule ^goods_type_info-([a-zA-Z]+)-([0-9]+).html$ index.php?act=goods&goods_id=$2&type=$1
    RewriteRule ^store_page_state-([a-zA-Z]+)-([a-zA-Z]+)-([0-9]+).html$ index.php?act=show_store&page=$1&state=$2&id=$3
    RewriteRule ^store_stc-([a-zA-Z]+)-([0-9]+).html$ index.php?act=show_store&id=$2&stc=$1
    RewriteRule ^store_stci-([0-9]+)-([0-9]+).html$ index.php?act=show_store&id=$1&stc_id=$2
    RewriteRule ^store_credit-([0-9]+).html$ index.php?act=show_store&op=credit&id=$1
    RewriteRule ^store_nav-([0-9]+)-([0-9]+).html$ index.php?act=show_store&id=$1&article=$2
    RewriteRule ^document-([a-zA-Z_]+).html$ index.php?act=document&code=$1

    这是我做的问题图片 http://img3.laibafile.cn/getimgXXX/1/0/photo1/2011/5/9/middle/72109562_23780241_middle.jpg

    到底怎么样修改.htaceess 的规则啊?大家帮帮忙,我在后台设置了伪静态,一按“用户团购” 或者 “信用团购” 就不能访问了!网店网址shopju.com(现在关闭了伪静态和二级域名,就是为着两个问题揪心啊,几天难眠!!!)

Leave a Reply to 温州SEO Cancel reply

Your email address will not be published. Required fields are marked *