【问题标题】:Redirect url using .htaccess使用 .htaccess 重定向网址
【发布时间】:2016-01-12 03:50:55
【问题描述】:

如何使用 htaccess 重定向 url。我只是尝试了很多,但找不到任何合适的方法。

https://demo.com/test.php?value=345

https://demo.com/test.php?convert=1&p=345

【问题讨论】:

  • 是....但它没有重定向。
  • RewriteEngine On RewriteCond %{QUERY_STRING} ^value=(\d+)$ [NC] RewriteRule ^test.php$ /test.php?convert=1&p=$1 [NC]

标签: apache .htaccess mod-rewrite lamp url-redirection


【解决方案1】:

试试这个

RewriteEngine on
RewriteRule  ^test.php/?$ test.php?convert=1&p=$1  [NC,L]

【讨论】:

    【解决方案2】:

    更简单的方法:

    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^value=(\d+)$ [NC]
    RewriteRule ^test\.php$ /test.php?convert=1&p=%1 [R=301,L,NC]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-22
      • 1970-01-01
      相关资源
      最近更新 更多