Forum Moderators: phranque
RewriteCond %{HTTP_REFERER}!^http://domain.com [NC]
RewriteCond %{HTTP_REFERER}!^http://www.domain\.com/* [NC]
RewriteCond %{HTTP_REFERER}!^http://.+\.domain\.com/* [NC]
RewriteRule /* [domain.com...] [R,L]
My problem is ... that I have one registration URL like this:
[domain.com...]
Since this script is located inside a subdirectory of the protected area, I keep getting bounced out ...
I'm sure there has to be a way to make a similar .htaccess file in the subdirectories that will ignore the previous one ... OR write some time of if/then scenario where "THIS URL" will not rewrite, but anything else matching the rewrite conditions will ...
Anyone got any suggestions?
Thanks!
Welcome to WebmasterWorld!
You can exclude that URL easily. You can also exclude some or all of the specific query string if you like. (Note that a query string is attached to a URL, but is not considered to be part of a URL).
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?domain\.com [NC]
RewriteCond %{REQUEST_URI}<->%{QUERY_STRING} !^/folder/index\.php<->.*name=Signup
RewriteRule .* http://www.domain.com/reject.html [R,L]
I note a pattern of mis-using "*" in your code. In the regular expressions used by mod_rewrite for pattern matching, "*" is a special character than means "any number of the previous character." Similarly, "." is a special character than means "any single character". If you wish to match a literal period or asterisk, you must precede it with a backslash, e.g. "\." as used above. The usage of special characters in regular expressions is much different than that of MSDOS and other operating systems, and much more powerful.
For more information on this subject, see the regular expressions tutorial cited in our forum charter [webmasterworld.com].
Jim
I'm still having the same problem with the redirect throwing me back to the rejection page when attemtping to access the account setup as I mentioned before ...
Here's what I put in the .htaccess per your code ...
AuthType Basic
RewriteEngine On
RewriteCond %{HTTP_REFERER}!^http://.+\.avs1\.com/* [NC]
RewriteCond %{HTTP_REFERER}!^http://.+\.avs2\.com/* [NC]
RewriteCond %{HTTP_REFERER}!^http://(.+\.)?mydomain\.com [NC]
RewriteCond %{REQUEST_URI}<->%{QUERY_STRING}!^/nuke/modules/\.php<->.*name=Your_Account
RewriteRule /* [mydomain.com...] [R,L]
Any clue as to why this isn't working?
Thanks again!
/nuke/modules/.php
That is what your pattern will match, and that the only file which will be excluded from the redirect (if the query is correct, too).
There are many other things that can cause problems -- Apache modules loaded in the wrong order, and such. But the most likely cause is regular-expressions errors. You have re-introduced several by using "/*" but I'll refer you to my previous post on that.
Jim
RewriteCond %{HTTP_REFERER} !^http://.+\.avs1\.co[b]m[/b] [NC]
RewriteCond %{HTTP_REFERER} !^http://.+\.avs2\.co[b]m[/b] [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mydomain\.com [NC]
RewriteCond %{REQUEST_URI}<->%{QUERY_STRING} !^/nuke/module[b]s\.p[/b]hp<->.*name=Your_Account
RewriteRule [b].*[/b] http://www.mydomain.com/buzz.html [R,L]
The same goes for the pattern in the rule itself; A pattern of "/*" would match any number of slashes, including zero. It's not so much that it is wrong, but that it is confusing. A pattern of ".*" means, "match any number of any characters" or simply put, "match anything".
Jim