【问题标题】:How can i customize my url using htaccess file如何使用 htaccess 文件自定义我的 url
【发布时间】:2022-01-26 06:23:23
【问题描述】:

#如何更改此网址? #

http://www.domain.in/product-category.php?id=3&name=house-hold&type=top-category

http://www.domain.in/product-category/house-hold

使用 .htaccess。

【问题讨论】:

  • 欢迎来到 SO,请在您的问题中添加您尝试过的 htaccess 规则文件,谢谢。
  • id=3 去哪儿了?您如何知道新 URL 中的 id? type=top-category 相同,新 URL 中缺少它,因此两者不能真正等效,或者第一个 URL 包含冗余/未使用的数据

标签: .htaccess


【解决方案1】:

这可能会对您有所帮助:

RewriteCond %{HTTP_HOST} ^www.domain.in
RewriteCond %{QUERY_STRING} name=(.*)&type
RewriteRule (.*).php /$1/%1?
Line 1 : we check the domain
Line 2 : we save the parameter name in a var (%1)
Line 3 : we rewrite rule with $1 (`REQUEST_URI` before `.php`) and %1.

https://htaccess.madewithlove.com?share=71f3a8dd-6b81-4620-b02c-2ae47297c8fc

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-10
    • 2014-12-29
    • 1970-01-01
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    • 2018-04-15
    • 2016-05-05
    相关资源
    最近更新 更多