【问题标题】:mod_rewrite taking over all the links on the pagemod_rewrite 接管页面上的所有链接
【发布时间】:2009-06-21 16:52:04
【问题描述】:

我使用 mod_rewrite 来重写我网站上的链接,如下所示:

mysite.com/store/<store_id>/<store_name>/<page>
mysite.com/store.php?id=<store_id>&page=<page>

例如:

mysite.com/store/1313/johnny-walker-inc/13
mysite.com/store.php?id=1313&page=13

但是,结果是,我的所有关联放置的链接现在都从链接的末尾开始,例如:

mysite.com/send_message.php

变成了

mysite.com/store/1313/johnny-walker-inc/send_message.php

我该如何解决这个问题?

这是我的mod_rewrite 代码,以防我弄错了:


RewriteRule ^store/([0-9]+)/[^/]+/([0-9]+)$ store.php?storeid=$1&page=$2 [L]

谢谢!

【问题讨论】:

    标签: php mod-rewrite seo


    【解决方案1】:

    您需要使您的链接相对于根,如下所示:

    <a href="/send_message.php">link</a>
    

    注意send_message.php之前的斜线。

    【讨论】:

      【解决方案2】:

      我个人只看到一种解决方案:将所有链接设为绝对链接。这不是 mod_rewrite 的直接问题,而是浏览器解释这些链接的方式。从他们的角度来看,您有一个目录结构,他们会相应地解释相对位置。

      【讨论】:

        【解决方案3】:

        其他解决方案包括 BASE href 或仅重写您向客户端显示的虚构上下文根可以引用的所有页面元素。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2011-01-15
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-04-27
          • 1970-01-01
          相关资源
          最近更新 更多