【问题标题】:Using 301 redirect inside htaccess file在 htaccess 文件中使用 301 重定向
【发布时间】:2023-03-21 01:00:01
【问题描述】:

我曾经有一个类似的链接: www.domain.com/index.php?id=IdParameter&place=true 但我不再使用"place=true"。 我希望所有这些链接看起来像: www.domain.com/index.php?id=IdParameter

没有"&place=true" 部分。 如果没有最后一部分,我如何将包括"place=true" 在内的链接重定向到它们自己?

谢谢

【问题讨论】:

    标签: .htaccess http-status-code-301 url-redirection


    【解决方案1】:

    将此代码放入您的DOCUMENT_ROOT/.htaccess 文件中:

    RewriteEngine On
    
    RewriteCond %{QUERY_STRING} ^(.+?)&place=true$ [NC]
    RewriteRule ^index\.php$ %{REQUEST_URI}?%1 [L,R]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多