【问题标题】:How to use mod_rewrite like this?如何像这样使用 mod_rewrite?
【发布时间】:2014-05-08 02:05:15
【问题描述】:

如何重写我这样的网址

/details.php?pid={id}
exam: /details.php?pid={ee76f41017c6f6aa762a2bfb7def83c5}

我想要这个

/products/{id}/name

我试试这个

RewriteEngine on
RewriteCond %{QUERY_STRING}     ^cat=(.*)
RewriteRule ^details.php /products/%1? [R=301]

还有这个

RewriteEngine On
RewriteRule ^products/([^/]*)$ /details.php?pid=$1 [L]

【问题讨论】:

  • 如果惹你生气,一整天很抱歉。
  • 我不知道要搜索的关键字。我的英语技能让我很难理解对不起阿吉安
  • 我没有“生气”。但是你需要在问题中展示你到底尝试了什么。这有助于回答它

标签: php .htaccess mod-rewrite


【解决方案1】:

这应该可行:

RewriteEngine on

RewriteCond %{THE_REQUEST} ^(GET|POST)\ /details\.php\?pid=(.*)\ HTTP
RewriteRule ^ /products/%2/name? [R=301,L]

以上内容将details.php?pid={id}改为products/{id}/name

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-14
    • 2019-04-09
    • 2017-09-10
    • 2022-07-15
    • 2012-11-18
    • 1970-01-01
    相关资源
    最近更新 更多