【问题标题】:How to Redirect URL using .htaccess?如何使用 .htaccess 重定向 URL?
【发布时间】:2012-03-26 19:28:18
【问题描述】:

我正在尝试使用 .htaccess 文件重定向 URL:

index.php?i=Dengue-NS1-ELISA-kit---Antigen&id=682&cat=0

index.php?i=Dengue-NS1-ELISA-kit---Antigen&id=682&cat=17

注意最后的 17

【问题讨论】:

    标签: .htaccess url redirect


    【解决方案1】:

    这是您需要放入 DOCUMENT_ROOT 下的 .htaccess 文件中的代码:

    Options +FollowSymLinks -MultiViews
    # Turn mod_rewrite on
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)cat=0(&.*|)$ [NC]
    RewriteRule ^index\.php$ index.php?%1%2&cat=17 [L,NC,R]
    

    【讨论】:

      【解决方案2】:

      这里也许你可以使用这个工具我一直在使用它http://www.htaccessredirect.net/

      【讨论】:

      • 我想将一个 url 重定向到另一个 url,我在这个 htaccessredirect.net 中找不到任何选项来重定向 url
      • 嗯,我不认为你可以用 htaccess 做到这一点,但对于 PHP,你可以使用 <?php echo"<meta http-equiv='REFRESH' content='0;url=http://www.the-domain-you-want-to-redirect-to.com'>"?>
      • 没有特定的页面/文件!两者都有 index.php,所以我不能使用元标记
      猜你喜欢
      • 2014-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-05
      • 1970-01-01
      相关资源
      最近更新 更多