简体   繁体   English

htaccess,从301重定向中删除查询字符串

[英]Htaccess , remove query string from 301 redirect

Thanks in advance for the help, 先谢谢您的帮助,

I have looked around the web and stack overflow for this answer and i keep trying to implement people answers but maybe I need a direct answer to the link i want to redirect. 我在网上四处寻找并找到了这个答案的堆栈,我一直在尝试实现人们的答案,但也许我需要直接重定向到我想要重定向的链接。

Im trying to get rid of the query string with the 301 redirect 我正在尝试使用301重定向摆脱查询字符串

i want this url: /Errors/PageNotFound.aspx?aspxerrorpath=/CheeseCrisps.aspx 我想要这个网址: /Errors/PageNotFound.aspx?aspxerrorpath=/CheeseCrisps.aspx

to be redirected to : http://www.cheesesticks.com 重定向到: http : //www.cheesesticks.com

but my result is this url: http://www.cheesesticks.com/?aspxerrorpath=/CheeseCrisps.aspx 但我的结果是该网址: http : //www.cheesesticks.com/? aspxerrorpath=/ CheeseCrisps.aspx

I dont want the get variables (query string) to still be on the url. 我不希望get变量(查询字符串)仍然在url上。 I just want the new url to be cheesesticks[DOT]com 我只想将新网址设为cheesesticks [DOT] com

Can someone help me write the redirect code? 有人可以帮我写重定向代码吗? thank you!! 谢谢!!

here is the 301 redirect i have in place currently which i know is wrong..... 这是我目前有的301重定向,我知道这是错误的.....
Redirect 301 /Errors/PageNotFound.aspx?aspxerrorpath=/CheeseCrisps.aspx [this is a place holder for the redirect url because stack overflow wont allow me to post more that 2 urls] 重定向301 /Errors/PageNotFound.aspx?aspxerrorpath=/CheeseCrisps.aspx [这是重定向网址的占位符,因为堆栈溢出不会允许我发布两个以上的网址]

You can use this rule in root .htaccess: 您可以在根.htaccess中使用此规则:

RewriteEngine On

RewriteCond %{QUERY_STRING} .+
RewriteRule ^Errors/PageNotFound\.aspx$ http://www.cheesesticks.com/? [L,R=301]

/? in the target URL will remove any existing query string. 目标网址中的将会删除所有现有的查询字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM