Search code examples
.htaccesshttp-redirectmod-rewriteurl-rewritinghttp-status-code-403

Block specific url with ? with htacess


Firstly, I can't get the correct code looking at other post here, not working for me hahahaha.

I would like to block this specific url: /2017/06/wonder-womannuestra-princesa-feminista.html?m=1 (Related to an old blogger url)

Don't know why but different ips, without referrer and user agent, are spamming (not a real visit cause after a redirection to the new one on WordPress they visit all the links in the url) my site always entering by this url and I would like to block ONLY this one.

I've tried to redirect this one with Redirection plugin but I have a redirection to all "?m=(*)" and this one is the one working, not the one related to the specific url.

I just used : RewriteCond %{REQUEST_URI} ^/2017/06/wonder-womannuestra-princesa-feminista.html?m=1 but it doesn't work.

Could you help, I think the problem is that I'm not witting the correct code due to the "?" character. Many thanks.


Solution

  • With your shown samples, attempts considering that you need to block url(mentioned in comments/question), if this is the case then try following. This rule will forbid this specific url from being accessed.

    Please these rules at top of your .htaccess file. Make sure to clear your browser cache before testing your URLs.

    RewriteEngine ON
    RewriteCond %{THE_REQUEST} \s/2017/06/wonder-womannuestra-princesa-feminista\.html\?m=1 [NC]
    RewriteRule ^ - [F,L]