Reputation: 21
I need to restrict access to any link that contains the word user
.
My rewrite rule looks like this
RewriteRule (^|/)user(/|$) - [F,L]
It works fine when http://sitename.com/user is used but does not work for http://sitename.com/?q=user
Can anyone suggest a fix for this ?
Thanks in advance
Upvotes: 1
Views: 133
Reputation: 12041
You'll have to check the request uri and the query string separately like this:
RewriteEngine On
RewriteCond %{REMOTE_HOST} !^123\.456\.789\.123$
RewriteCond %{REQUEST_URI} ^/user$ [OR]
RewriteCond %{QUERY_STRING} ^q=user$
RewriteRule ^(.*)$ / [R=302,L]
Upvotes: 1