查询使用wordpress重定向问题

时间:2012-01-17 21:38:39

标签: wordpress .htaccess mod-rewrite redirect

我正在尝试为我的类别页面设置查询重定向

目前网址如下:

  http://chunkydeals.com/daily-deals/?category=alldeals

我试图让它成为:

  http://chunkydeals.com/daily-deals/alldeals/

我的htaccess代码如下:

  # BEGIN WordPress

  <IfModule mod_rewrite.c>

  RewriteEngine On

  RewriteBase /
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
  RewriteCond %{QUERY_STRING} ^category=([a-z])*)$
  RewriteRule ^daily-deals/$ http://chunkydeals.com/daily-deals/%3/? [R=301,L]

  </IfModule>

  # END WordPress

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:1)

您是否尝试将QUERY_STRING规则置于重写为index.php的规则之上? (这会阻止正则表达式^daily-deals/$匹配)

RewriteBase /

RewriteCond %{QUERY_STRING} ^category=([a-z])*)$
RewriteRule ^daily-deals/$ http://chunkydeals.com/daily-deals/%1/? [R=301,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]