LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-31-2020, 06:08 AM   #1
Michael Uplawski
Member
 
Registered: Dec 2015
Location: Outside, most of the time.
Posts: 967
Blog Entries: 26

Rep: Reputation: 558Reputation: 558Reputation: 558Reputation: 558Reputation: 558Reputation: 558
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.

Last edited by Michael Uplawski; 10-31-2020 at 06:10 AM. Reason: moved a comma
 
Old 11-01-2020, 04:26 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,768

Rep: Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843
Hi Michael,

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

Regards
 
1 members found this post helpful.
Old 11-02-2020, 01:02 PM   #3
Michael Uplawski
Member
 
Registered: Dec 2015
Location: Outside, most of the time.
Posts: 967

Original Poster
Blog Entries: 26

Rep: Reputation: 558Reputation: 558Reputation: 558Reputation: 558Reputation: 558Reputation: 558
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.
 
Old 11-12-2020, 02:15 PM   #4
Michael Uplawski
Member
 
Registered: Dec 2015
Location: Outside, most of the time.
Posts: 967

Original Poster
Blog Entries: 26

Rep: Reputation: 558Reputation: 558Reputation: 558Reputation: 558Reputation: 558Reputation: 558
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.
 
Old 11-13-2020, 11:27 AM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,768

Rep: Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843
Quote:
Originally Posted by Michael Uplawski View Post
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
 
2 members found this post helpful.
Old Yesterday, 07:31 AM   #6
Michael Uplawski
Member
 
Registered: Dec 2015
Location: Outside, most of the time.
Posts: 967

Original Poster
Blog Entries: 26

Rep: Reputation: 558Reputation: 558Reputation: 558Reputation: 558Reputation: 558Reputation: 558
Quote:
Originally Posted by bathory View Post
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].
 
  


Reply

Tags
hopeless


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] /etc/udev/rules.d/40-libsane.rules and /etc/udev/rules.d/S99-2000S1.rules missing LABEL=libsane_rules_end mumahendras3 Slackware 6 03-09-2020 03:27 AM
[SOLVED] Apache ReWrite Rules .HTACCESS FILE Erudes Linux - Server 12 02-25-2020 04:07 PM
facing problem in writing htaccess rewrite rules bloodstreetboy Programming 1 09-04-2015 05:36 PM
[SOLVED] Debian, Lenny, suEXEC, Apache2, .htaccess rewrite rules don't work anymore. Mogget Linux - Server 1 07-10-2010 07:33 PM
dysfunctional bootloader skorchio Linux - Software 1 07-26-2004 11:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration