普通网友 2013-04-12 15:11
浏览 23
已采纳

Url重写域名[关闭]

Ok so i have hosting with godaddy and i have 2 websites hosted with them. I make a htaccess rule and add it into my main dir and it effect both domain names. Im just wondering if there anything i can add to it to only work for the one domain name ?? My mod rewrite rule is has follwed

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)_ index.php?pageid=$1

When i add this to my main dir it effect both websites i have hosted. The rule ment to be changing this mysite.com?index.php to this mysite.com/index_

But has i have said i need to some how set a domain name in side it some how.

  • 写回答

1条回答 默认 最新

  • duanniu3385 2013-04-12 15:57
    关注

    Add this line before your RewriteRule

    RewriteCond %{HTTP_HOST} ^www.mydomainname.com$
    

    Your rule will affect only this domain, your .htaccess should look like this :

    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www.mysite.com$
    RewriteRule (.*) /index.php?pageid=$1
    

    This would match

    http://www.mysite.com/week1
    

    and rewrite it to

    http://www.mysite.com/index.php?pageid=week1
    

    Then you can access $_GET['pageid'] to get the value

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?