【问题标题】:.htaccess redirection rule.htaccess 重定向规则
【发布时间】:2011-12-20 19:06:22
【问题描述】:

任何人都可以帮助解决 .htaccess URL 重写规则。

我需要像这样重定向页面:

www.website.com/index.php?a=some-word-some-other-word
www.website.com/index.php?a=something
www.website.com/index.php?a=some-other-thing

所有这些页面的内容都与 www.website.com/index.php 相同

到

www.website.com/index.php 或 www.website.com/

我已经问过了,我得到了这个:

RewriteEngine On
RewriteBase /

#if the query string has an a parameter
RewriteCond %{QUERY_STRING} (^|&)a= [NC]
#Redirect and remove query string parameters
RewriteRule .*  http://www.website.com/? [R=301,L]

这样做,它将这些页面重定向到主页(站点的根目录)。但我有一些网页的网址如下:

i.php?a=something-something-something

问题是上面的 .htaccess 代码也会影响这些链接。

任何人都可以编写该代码来重定向基于index.php?a=的页面链接而不是也用于i.php?a=。

【问题讨论】:

    标签: .htaccess url-rewriting


    【解决方案1】:

    试试这个,告诉我它是否有效:

    RewriteEngine On
    RewriteBase /
    
    #if the query string has an a parameter
    RewriteCond %{QUERY_STRING} (^|&)a= [NC]
    #Redirect and remove query string parameters
    RewriteRule ^index\.php$  http://www.website.com/? [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-12-22
      • 2011-01-05
      • 1970-01-01
      • 2020-11-01
      相关资源
      最近更新 更多