【问题标题】:How to rewrite URLs in PHP using .htaccess, I have tried it but it's not working?如何使用 .htaccess 在 PHP 中重写 URL,我已经尝试过了,但它不起作用?
【发布时间】:2020-09-16 04:35:36
【问题描述】:

谁能帮我在php中重写url... http://localhost:81/cabnotels/Domestic-tours/tour.php?Delhi&india%27s-golden-triangle-tour&type=tour&id=19

这是当前的 URL,我想重写为.. http://localhost:81/cabnotels/Domestic-tours/tour/Delhi/india's-golden-triangle-tour/tour/19

请帮忙.. 提前谢谢你。

【问题讨论】:

  • 请分享您尝试过的代码,我们是来帮助您的,而不是为您编写代码:) 还要确保在您的安装中启用mod_rewrite
  • 请不要到处乱贴标签。这个问题与javascriptphpmyadmin 几乎没有关系,甚至对于标记php 到目前为止也没有真正的充分理由(标签已删除。)

标签: url-rewriting dynamic-url


【解决方案1】:

您不能像在(印度)那样在您的网址中使用逗号,您可以使用 htaccess 重写您的网址,例如:

RewriteRule ^cabnotels/domestic-tours/tours/([^/]*)/([^/]*)/tour/([^/]*)$ tour.php?$1&$2&$3&$4 [QSA,L,NC]

或者,如果您只有一个 URL:

RewriteRule ^cabnotels/Domestic-tours/tour/Delhi/indias-golden-triangle-tour/tour/19$ cabnotels/Domestic-tours/tour.php?Delhi&india%27s-golden-triangle-tour&type=tour&id=19

【讨论】:

  • 我用过这个---RewriteRule ^cabnotels/domestic-tours/tour/([^/]*)/([^/]*)/tour/([^/]*) $ tour.php?$1&$2&$3&$4 [QSA,L,NC] 但它不起作用,我也删除了印度并简单地添加了印度,这是一个动态页面。
猜你喜欢
  • 2018-12-07
  • 2016-04-08
  • 1970-01-01
  • 2014-06-06
  • 2015-09-16
  • 2023-04-05
  • 2019-12-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多