【问题标题】:Htaccess Redirect URL with Parameter带参数的 Htaccess 重定向 URL
【发布时间】:2014-11-23 20:11:23
【问题描述】:

使用参数重定向以下页面的正确 htaccess 命令是什么:

http://www.domain.com/directory/file.php?pageId=1234

到页面:

http://www.domain.com/page.php

【问题讨论】:

  • 您希望将任何pageId 值(即/directory/file.php?pageId=567)重定向到/page.php 还是仅重定向/directory/file.php?pageId=1234
  • @anubhava only /directory/file.php?pageId=1234

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


【解决方案1】:

我相信这会奏效:

RewriteEngine on
RewriteRule ^directory/file.php.*$ page.php [L,R]

如果你希望它是一个“临时重定向”,你可以使用 R=302 而不是 R

【讨论】:

    【解决方案2】:

    您可以在 DOCUMENT_ROOT/.htaccess 文件中使用此代码:

    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} \s/+file\.php\?pageId=1234[\s&] [NC]
    RewriteRule ^ /page.php? [R=302,L,NE]
    

    【讨论】:

      猜你喜欢
      • 2014-04-29
      • 1970-01-01
      • 1970-01-01
      • 2022-07-01
      • 1970-01-01
      • 2022-12-29
      • 1970-01-01
      • 2014-01-06
      • 1970-01-01
      相关资源
      最近更新 更多