【问题标题】:Replace query string with '/' via .htaccess file [duplicate]通过 .htaccess 文件将查询字符串替换为“/”[重复]
【发布时间】:2018-08-03 18:10:01
【问题描述】:

http://thewebsitedemo.com/Just-dial/Chandigarh.php?categories=hotel&searchkeyword=tamarind

提交表单后我有上面的网址。我想用'/'替换查询字符串静态变量。

例如。我需要这样的网址: http://thewebsitedemo.com/Just-dial/Chandigarh/hotel/tamarind

【问题讨论】:

  • 用 url 和 mod rewrite 试过了吗?

标签: php string .htaccess url replace


【解决方案1】:

试试:

RewriteEngine On
RewriteCond %{THE_REQUEST} \ /+Just-dial/Chandigarh\.php\?categories=([^&]+)&searchkeyword=([^&\ ]+)
RewriteRule ^ /Just-dial/Chandigarh/%1/%2? [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^Just-dial/Chandigarh/([^/]+)/([^/]+)$ /Just-dial/Chandigarh.php?categories=$1&searchkeyword=$2 [L]

【讨论】:

  • 使用 .htacess 文件更改 URL 后不显示结果
猜你喜欢
  • 2012-07-10
  • 2021-06-29
  • 2014-05-10
  • 2012-07-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-06
相关资源
最近更新 更多