LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   My own version of dysfunctional .htaccess rewrite rules (https://www.linuxquestions.org/questions/linux-networking-3/my-own-version-of-dysfunctional-htaccess-rewrite-rules-4175684490/)

Michael Uplawski 10-31-2020 05:08 AM

My own version of dysfunctional .htaccess rewrite rules
 
Here's mine

Code:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_REFERER} !http://(www.)?uplawski.eu/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(gif|jpg|jp2|png)$ http://www.uplawski.eu/images/klaunicht.jpg [L]

This is, of course, an attempt to prevent hotlinking image-files. I reduced the authentic .htaccess content to these lines for simplicity. But they still to not have an effect. In the draft for a blog-post on LQ, for example, I can freely link to any image files on my web-site and they will be displayed.

I am not insisting on the fact that, a few years back, when I first used a .htaccess file, I managed to prevent hotlinks this way. It probably lured me into thinking that I had understood the stuff.

I clearly do not and probably will never. Maybe point me at the error in the above code and I just try to get along...

TY.

bathory 11-01-2020 03:26 AM

Hi Michael,

You may try the apache official mod_rewrite ways to avoid image hotlinking

Regards

Michael Uplawski 11-02-2020 12:02 PM

Thank you bathry.

Of course, I cannot say, why this documentation would be better than all the others that I have scrutinized in the meantime, but I will copy&paste these code-examples, too, just to see what happens. I will report back in any case, but I am coughing too much tonight and have different interests for the next days.

Michael Uplawski 11-12-2020 01:15 PM

Nope.

The differences between the proposed rules from apache.org and my own are negligible but I tried them anyway. With the same result, that hotlinking images from my site is still possible and the sought redirection to an alternate image is not done.

I suppose that the Web-Server is quite simply lacking a capability but do not yet have any answers from the administrators.

bathory 11-13-2020 10:27 AM

Quote:

Originally Posted by Michael Uplawski (Post 6184704)
Nope.

The differences between the proposed rules from apache.org and my own are negligible but I tried them anyway. With the same result, that hotlinking images from my site is still possible and the sought redirection to an alternate image is not done.

I suppose that the Web-Server is quite simply lacking a capability but do not yet have any answers from the administrators.

The rules should work.
Perhaps apache does not read .htaccess files. Check if you have a AllowOverride ... directive in apache config file(s)
You need at least a
Code:

AllowOverride FileInfo
for rewrite rules to work from inside a .htaccess file.

Regards

Michael Uplawski 11-24-2020 06:31 AM

Quote:

Originally Posted by bathory (Post 6184949)
Code:

AllowOverride FileInfo

I think I informed the people who live closer to the server in question, but have not had any specific reaction. For me, the thread is closed, but not [Solved].


All times are GMT -5. The time now is 03:39 AM.