How to disable "?i=1" parameter in URL
Asked Answered
L

3

9

My website is running on InfinityFree hosting and it ads ?i=1 suffixes (like www.mysite.com/?i=1, or /?i=2, or /?i=3) to every URL to protect websites against malicious bots, as they say.

But of course, I don't like these suffixes and want to disable them (simply redirecting www.mysite.com/anypage/?i=1 to www.mysite.com/anypage/). Note that I don't want to disable all GET parameters, but only these i=1, i=2 and i=3.

I think it could be done using .htaccess. Can someone help me, please?

Littoral answered 13/7, 2017 at 12:21 Comment(2)
You should probably ask them how to turn it off if it's causing you a problem. This is definitely not a question for Stack Overflow, which is a programming Q&A Site. You could ask at webmasters.stackexchange.com but they'll almost certainly want to know what you mean by 'adds a suffix' does it return a http redirect to the new url? Does it modify all links in your HTML? etc.Serg
@JeffUK, they say it's necessary for InfinityFree users, so I can't disable it in a "legal" way. I just want to know if there's a htaccess code to redirect all the URLs with "I" to the URLs without it.Littoral
L
19

Well, I've solved the problem using a code from this question. I've just added this code in my .htaccess, and now it redirects all the URLs with "i" to the URLs without it.

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)i=[^&]+(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]
Littoral answered 4/8, 2017 at 15:45 Comment(1)
worked very well.. but now browser is showing that tracking attempt blocked.Metric
F
1

You need to turn the RewriteEngine on first.

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)i=[^&]+(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]
Feebleminded answered 17/8, 2021 at 17:56 Comment(0)
A
0

Can't edit accepted answer.

Added regex "&?" to avoid empty key/value:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)i=[^&]+&?(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]
Anarchist answered 8/8, 2023 at 23:47 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.