Forum Moderators: phranque
I have added this type of rewrite to my .htaccess:
RewriteCond %{HTTP_REFERER} ^https?://(www\.)?domain\.com/showthread\.php\?t=12345 [NC]
RewriteRule .* /somewhere/smallfile.jpg [R=301,L] It redirects but it isn't working how I should expect.
When a browser hits the source URL, the browser is rewritten as:
[myredirect.com...]
How does one get that
off the end of rewritten URL?
?f=1
RewriteRule .* /somewhere/smallfile.jp[b]g?[/b] [R=301,L]
RewriteCond %{REQUEST_URI} !^/somewhere/smallfile\.jpg$
RewriteCond %{HTTP_REFERER} ^https?://(www\.)?domain\.com/showthread\.php\?t=12345 [NC]
RewriteRule .* /somewhere/smallfile.jpg? [R=301,L]
RewriteCond %{HTTP_REFERER} ^https?://(www\.)?domain\.com/showthread\.php\?t=12345 [NC]
RewriteRule !^somewhere/smallfile\.jpg$ /somewhere/smallfile.jpg? [R=301,L]
RewriteCond %{REQUEST_URI} !^/somewhere/smallfile\.jpg$
RewriteCond %{HTTP_REFERER} ^https?://(www\.)?domain\.com/showthread\.php\?t=12345 [NC]
RewriteRule \.(jpe?g¦gif¦bmp¦png)$ /somewhere/smallfile.jpg? [R=301,L]
Also be aware that some portion of the requests from that site will come to your server without an HTTP_REFERER header, so they won't be redirected. Because it is up to the client to send that header, and because intervening corporate and ISP caching proxies may effectively remove that headers, there's nothing we can do about it when using referrer-based access control.
Flush your browser cache before testing any new code on your server.
Jim