【问题标题】:301 redirect url with parameters to non-trailing slash url (htaccess)301 将带有参数的 url 重定向到非斜杠 url (htaccess)
【发布时间】:2018-12-21 05:13:09
【问题描述】:

您好,我们在 apache 服务器中使用 wordpress。

我们希望 301 将带有斜杠的特定路径重定向到非斜杠。

例子:

https://www.example.com/action/villa/?city=Ankara&area=etimesgut/

https://www.example.com/action/villa/?city=Ankara&area=etimesgut

我们如何使用 htaccess 做到这一点?

我已经在网站上搜索过,但我找不到像 htaccess 这样的内容重定向 url。

感谢您的帮助

【问题讨论】:

  • 您是如何在查询字符串中获得第一个带有斜杠的 URL?

标签: wordpress .htaccess redirect slash trailing


【解决方案1】:

要删除尾部斜杠,请将其添加到您的 .htaccess

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]

确保在测试之前清除缓存。

【讨论】:

  • 但是我们想重定向路径,就像在示例中不是所有的 url :/
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-22
  • 2018-02-19
相关资源
最近更新 更多