简体   繁体   中英

Remove symbol and text from url htaccess

I need to remove some specific text (and all characters after it from a url) - have tried several options, but I can't get any of them to work, a sample url is:

/yacht-sales/yacht/eclipse1?title=http://www.oceanindependence.com/yacht-sales/yacht/daydream&submit=

It's everything from the ?title= - that needs to be removed, so the final url would be:

/yacht-sales/yacht/eclipse1

there is another site on the same server that uses ? in it's url's, so removing everything from the ? onwards did cause problems when I tried it, and I did also try:

RewriteCond %{QUERY_STRING} ^?title=http$ [NC]
RewriteRule ^ %{REQUEST_URI}? [R=301,L,NE] 

But this didn't work, sorry am not really good at things like this, if anyone can help at all?

Cheers

%{QUERY_STRING} doesn't contain first ? and since its not ending with http hence don't put $ there.

You can use this rule:

RewriteCond %{QUERY_STRING} (^|&)title=http.+ [NC]
RewriteRule ^ %{REQUEST_URI}? [R=301,L,NE]

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