.htaccess重定向(匹配url模式,重定向到页面)

时间:2014-08-27 13:10:09

标签: .htaccess redirect

我无法解决这个问题:

这是原始网址格式:

  • /supportcp/index.html
  • /supportcp/content/edit.html
  • /supportcp/members/user_banning.html
  • / supportcp / *

所有人都应该重定向到/支持

我从以下.htaccess代码开始,但不幸的是我最终得到了错误的网址。

RewriteCond %{QUERY_STRING} !=""
RewriteCond %{QUERY_STRING} !page=supportcp
RewriteRule ^index.php /support/ [R,L]

结果:/ support /?/ support /(错误)

非常感谢帮助!

1 个答案:

答案 0 :(得分:1)

您需要在目标URI中附加?以删除任何查询字符串:

RewriteEngine On
RewriteBase /

# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteCond %{QUERY_STRING} !=""
RewriteCond %{QUERY_STRING} !page=supportcp
RewriteRule ^index\.php$ /support/? [R,NC,L]

# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
相关问题