开发者

htaccess redirect referrer - but stop redirecting on new page

We have a problem with someone poaching the extensive ukulele song list at http://scorpex.net/Uke for a pa开发者_如何学Pythonid app.

Negotiations have broken down so any requests from the app are going to be redirected to a new "these songs are being ripped off" pdf file.

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^theapp [NC]
RewriteRule \.*$ http://scorpex.net/stop/stealing/uke/songs/please.pdf [R]

The problem is it creates a redirect loop - I can see why, I am not sure how to resolve it. Ideas people?


Suggestions: Only apply the rule if the filename doesn't contain please.pdf.

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^theapp [NC]
RewriteCond %{REQUEST_FILENAME} !please.pdf
RewriteRule \.*$ http://scorpex.net/stop/stealing/uke/songs/please.pdf [R,L]

or only do the redirect when the user tries to access an mp3 file.

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^theapp [NC]
RewriteRule \.mp3$ http://scorpex.net/stop/stealing/uke/songs/please.pdf [R,L]


Your Rewrite rules should look something like this I believe:

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} ^.*theapp.*$ [NC]
RewriteRule .* http://scorpex.net/stop/stealing/uke/songs/please.pdf [R]


I am not sure if it is the right or even the best solution, but this works:

In the target directory I added another .htaccess with RewriteEngine Off I am not experienced with either regexp or .htaccess but can muddle my way through by following examples so I am interested in comments about this approach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜