简体   繁体   中英

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

i want this url: /Errors/PageNotFound.aspx?aspxerrorpath=/CheeseCrisps.aspx

to be redirected to : http://www.cheesesticks.com

but my result is this url: http://www.cheesesticks.com/?aspxerrorpath=/CheeseCrisps.aspx

I dont want the get variables (query string) to still be on the url. I just want the new url to be 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.....
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]

You can use this rule in root .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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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