.htaccess 删除重定向时附加的查询参数

.htaccess 删除重定向时附加的查询参数,.htaccess,redirect,http-redirect,.htaccess,Redirect,Http Redirect,我有WordPress.htaccess文件,这里是它的外观 # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # the following three lines will work for all subdomains RewriteCond %{HTTP_HOST} !^example\.net$ [NC] RewriteCond %{HTTP_HOST} !^www\.exam

我有WordPress.htaccess文件,这里是它的外观

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# the following three lines will work for all subdomains
RewriteCond %{HTTP_HOST} !^example\.net$ [NC]
RewriteCond %{HTTP_HOST} !^www\.example\.net$ [NC]
RewriteRule . "http://www.example.net/" [R=301,L]

# the following two lines will redirect non-www to www version of the domain
RewriteCond %{HTTP_HOST} ^example\.net
RewriteRule ^(.*)$ "http://www.example.net/$1" [R=301,L]

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

# Wordfence WAF

<Files ".user.ini">
<IfModule mod_authz_core.c>
    Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
    Order deny,allow
    Deny from all
</IfModule>
</Files>

# END Wordfence WAF
#开始WordPress
重新启动发动机
重写基/
#以下三行适用于所有子域
重写cond%{HTTP_HOST}^示例\.net$[NC]
重写cond%{HTTP_HOST}^www\.example\.net$[NC]
重写规则。"http://www.example.net/“[R=301,L]
#以下两行将非www重定向到域的www版本
重写cond%{HTTP_HOST}^example\.net
重写规则^(.*)”http://www.example.net/$1英寸[R=301,L]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#Wordfence WAF
要求全部拒绝
命令拒绝,允许
全盘否定
#结束字围栏WAF
我想将我的子域重定向到主域

问题是,如果我点击类似的,
subdomain.example.net/anystring
它会成功重定向到
example.net

但是,如果我点击像,
subdomain.example.net/anystring?anytext
它会成功重定向到
example.net?anytext

所以这里添加了
?任何文本
,我需要删除附加到
子域.example.net

我试过几次,但都没有成功


我请求您的帮助。

添加
为了防止查询字符串附加到替换url,请更改代码中的这两行:

RewriteRule . "http://www.example.net/" [R=301,L]
据此:

RewriteRule . "http://www.example.net/?" [R=301,L]
RewriteRule ^(.*)$ "http://www.example.net/$1?" [R=301,L]
这一行:

RewriteRule ^(.*)$ "http://www.example.net/$1" [R=301,L]
据此:

RewriteRule . "http://www.example.net/?" [R=301,L]
RewriteRule ^(.*)$ "http://www.example.net/$1?" [R=301,L]

您好,这解决了问题,但还有一件事,如果URL类似于
subdomain.example.net/anytext?d
它将重定向到
example.net?d
更改此行规则。“?”[R=301,L]到这个重写规则^(.*)”?“[R=301,L]好的,谢谢,你能帮我重定向
http://www.exaple.com/?extratext=1
http://www.example.com/