【问题标题】:How to rewrite my URL so that it uses the names of category's and products?如何重写我的 URL 以使其使用类别和产品的名称?
【发布时间】:2017-03-04 20:31:16
【问题描述】:

我正在使用 .htaccess 文件来重写我的 URL。它删除了.php。这很好用。但是,在我的网上商店系统中,我有产品、类别和主要类别。我希望我的 URL 采用这种形式:

首页 >> #NameOfMainCategory >> #NameOfCategory >> #TypenumberOfProduct

原来的网址是这样的:

Webshop/product.php?$main_cat=Cables&cat=VideoCables&product=tup7

我找到了this 主题,但它并没有真正帮助我。我怎样才能重写这个 url 以便我得到这个:

首页/电缆/VideoCables/tup7

【问题讨论】:

    标签: php .htaccess url-rewriting


    【解决方案1】:

    要重写,必须先捕获(...)原始请求的部分,然后在目标中使用$1$2、...这些部分

    RewriteRule ^Home/(.*?)/(.*?)/(.*?)$ /Webshop/product.php?$main_cat=$1&cat=$2&product=$3 [L]
    

    【讨论】:

      猜你喜欢
      • 2017-02-25
      • 2013-08-28
      • 1970-01-01
      • 1970-01-01
      • 2016-09-02
      • 2014-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多