Forum Moderators: phranque
Regards,
Clint
Also, you can simply return a code of 403 Forbidden to this user by changing the
rule to
RewriteRule .* - [F,L]
If you are putting this redirect on a "professional" site, that is the preferred
approach.
I'm not sure if the above is what you want when you say your unwelcome visitor
"comes from" example.com or a certain IP address; If you meant "clicks on a
link on example.com to get to my site", then you would use
RewriteCond %{HTTP_REFERER} ^example.com$
Note also that this covers "example.com" only. If you want www.example.com, then
you need
RewriteCond %{HTTP_REFERER} ^www.example.com$
or you could cover both with
RewriteCond %{HTTP_REFERER} example.com$
(no leading text anchor)
Note the [OR] at the end of the first RewriteCond. The default behavior of
mod_rewrite is to "and" all RewriteCond lines together, and only perform the
rewrite if ALL conditions are met.
Be careful with mod_rewrite - One typo may lock all of your users out - even
yourself. You must have ftp access to recover from such a problem. Short of
locking evryone out, you may unintentionally lock out just some users or lock
all users out of just some pages. So, make sure to test your site immediately
after changing anything in .htaccess! Then watch your error and access logs
like a hawk for at least few hours.
Treat .htaccess and mod_rewrite like a dangerous weapon - crucial to survival
in trained hands, dangerous to survival of the careless.
For more authoritative details as well as more warnings about the power of
mod_rewrite, check out
[httpd.apache.org...]
Hope this helps,
Jim
It is good to know I was on the right path using the rewrite engine and htaccess.
I am off now to study all I can about rewrite.
Regards,
Clint