hotlink protection compatibility issue with uc browser - .htaccess

i am using this code in cpanel for hotlink protection and its working fine in all browser, except uc browser
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://([^.]+\.)?domain1\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://([^.]+\.)?domain2\.net/ [NC]
RewriteCond %{HTTP_USER_AGENT} !(Mediapartners-Google|googlebot-image|msnbot|psbot) [NC]
RewriteRule \.(php|bm|zip|mp4|mkv)$ http://errordomain.com/404.html [R,NC]
</IfModule>
uc browser lead me to 404 every time , even from domain1.com and domain2.net. any suggestion

Related

How to allow access to files for all sites while maintaining htaccess redirection

I wanted to keep the redirect rule. but I don't want to have to add site by site so that they can display the image. how can i change this rule so that it can do this trick? thanks in advance. Any help is welcome :)
actual htaccess
<Files ~ "\.(jpg|jpeg|png|gif)$">
Order allow,deny
allow from all
</Files>
RewriteEngine on
RewriteCond %{QUERY_STRING} (?:^|&)fbclid=
RewriteRule ^ / [L,R=permanent]
RewriteCond %{HTTP_REFERER} !^https://mysite,com [NC]
RewriteCond %{HTTP_REFERER} !^https://www.facebook,com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.facebook,com/ [NC]
RewriteCond %{HTTP_REFERER} !^https://externalsite,com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://externalsite2,com/ [NC]
RewriteCond %{HTTP_REFERER} !^https://mysite,com.*$ [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ https://mysite,com [NC,R,L]
<IfModule mod_php4.c>
php_value engine off
</IfModule>
<IfModule mod_php5.c>
php_value engine off
</IfModule>
<Files ~ "\.((php[0-9]?)|p?html?|pl|sh|java|cpp|c|h|js|rc)$">
Order allow,deny
Deny from all
</Files>
RewriteCond %{HTTP_REFERER} !^https://mysite,com [NC]
RewriteCond %{HTTP_REFERER} !^https://www.facebook,com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.facebook,com/ [NC]
RewriteCond %{HTTP_REFERER} !^https://externalsite,com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://externalsite2,com/ [NC]
RewriteCond %{HTTP_REFERER} !^https://mysite,com.*$ [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ https://mysite,com [NC,R,L]
I wanted to give full access to other sites to incorporate my content ... redirecting if you access the file directly at example.com/uploads/test.gif
If you simply want to block direct access (in which case the Referer header is empty) and allow all other sites to link to your images (basically the opposite of "hotlink protection") then you can replace the above rule (that redirects such requests to the root) with the following:
RewriteCond %{HTTP_REFERER} ^$
RewriteRule \.(jpg|jpeg|png|gif)$ https://example.com/ [NC,R,L]
This redirects all direct requests to the root / home page.
(You had erroneous commas , in your original directives that would have prevented this from working?!)
HOWEVER, basing this redirect on the HTTP Referer is unreliable - you will get false positives. The Referer is sent by the browser - so the user can control (and suppress) what is sent. The website that is linking to you can also set a referrer-policy that suppresses the HTTP Referer being sent - so all requests from some sites might look like direct requests anyway and end up being blocked. There is no way around this.

httaccess in Wordpress - point to subfolder + redirect to https

The old .htaccess redirects automatically to https protocol :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
But I saw there is no pointer to the subfolder via htaccess. The ex-developper used this :
[root]index.php
<?php include_once("wordpress/index.php"); ?>
It seems to create several bugs :
on the admin panel side, there is a redirection https://my-site/wp-admin/ to https://my-site/wordpress/wp-admin/ but not on the front-end.
Sometimes on the admin side, there are some redirection like this : https://my-site/wp-admin/... which generates bugs.
So... It´s confusing and I wish to clean this with a simpler way : I would like :
point the domain to the subfolder wordpress and works for front-end and back-end
keep the automatic redirection http to https
I tried this without success :
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^(www.)?docpeda.be$
RewriteRule ^(/)?$ wordpress/index.php [L]
</IfModule>
I´m sure it´s really easy to do it but I need some helps.
This is what you should put in the .htaccess file if it's a subfolder, hopefully this will solve your issue (just copy and paste). It will also make the site secure.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^(www.)?docpeda.be$
RewriteCond %{REQUEST_URI} !^/wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wordpress/$1
RewriteCond %{HTTP_HOST} ^(www.)?docpeda.be$
RewriteRule ^(/)?$ wordpress/index.php [L]
</IfModule>

Strange hotlink protection issues - .htaccess

I used the rules that should work, and have worked in the past but every variation I try it continues to serve a the image (clearing cache each time). Other rules like URL rewrites work fine.
I would provide a copy of the error logs but I can't seem to gain access to this through FTP, neither can the person running the server droplet.
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(sub\.)?example.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
I know this seems like it should all be working, everyone says the codes are correct. Yet for the past few weeks I have been trying find solutions. I'm positive there is something else going on that is not related to the code, I just need help finding it as I'm not too experienced working extensively with htaccess.
Full htaccess:
ErrorDocument 404 /404.php
AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /path/to/.htpasswd
Require valid-user
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?dev.mangazing\.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
Is this what you're looking for?
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?sub.example.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
EDIT
Please try to replace your rewrite rule line
Replace:
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
With:
RewriteRule \.(jpg|jpeg|png|gif)$ http://icons.iconarchive.com/icons/tatice/cristal-intense/256/Ad-Aware-icon.png [NC,R,L]
Your code will look like:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?sub.example.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://icons.iconarchive.com/icons/tatice/cristal-intense/256/Ad-Aware-icon.png [NC,R,L]
Or
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?dev.mangazing\.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://icons.iconarchive.com/icons/tatice/cristal-intense/256/Ad-Aware-icon.png [NC,R,L]
and visit 1 of your image urls, I hope this is working for you.. remember to upload a replacement picture to a server and change replacement URL in the new rewrite rule, this can be done with a transparent 1 pixel image (Not a html/php etc document, it must be an image file!) free hosted at google pages or any other webhosting service you like..
Edit 2
Please try with <IfModule mod_rewrite.c>:
<IfModule mod_rewrite.c>
RewriteEngine on
#Your other anti hotlink commands here...
</IfModule>
More methodes to protect image hotlinking: creating the ultimate .htaccess anti hotlinking strategy

Referrer not blocked by htaccess

I am trying to help a black funeral home stop harassment by a racist site. One request they made was that I prevent direct linking from the racist site to theirs.
The following is the whole .htaccess
When I go to the harassing site (name not listed below as it contains racial slurs) and click one of their links to the funeral home I am never blocked.
What did I do wrong?
ErrorDocument 404 /index.php
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} racistsitenamehere\.net [NC]
RewriteCond %{HTTP_REFERER} semalt\.com [NC]
RewriteRule .* - [F]
RewriteEngine on
RewriteBase /
RewriteRule ^([^/\.]+)/?$ /page.php?page=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /page.php?page=$1&sub=$2 [L]
# block semalt
order allow,deny
deny from 85.58.23.115
deny from 177.21.203.170
allow from all
You're missing an [OR], since the referer can't be BOTH (e.g. AND) of those, you want one or the other to be true:
RewriteCond %{HTTP_REFERER} racistsitenamehere\.net [NC,OR]
RewriteCond %{HTTP_REFERER} semalt\.com [NC]
RewriteRule .* - [F,L]
Also wouldn't hurt to have an L flag in there.

Redirect non-www to www with SEO-friendly query strings

I am trying to redirect my site from non-www to www. My site is at [http://www.alennuskoodit.us]. I try to make it so that all requests without www would be redirected to www. Normal stuff so far.
However, if I go to http://alennuskoodit.us I end up here: http://www.alennuskoodit.us/index.php?qstr=http://www.alennuskoodit.us
This is the .htaccess:
Options +FollowSymLinks
Options +Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
# going to install folder
RewriteCond %{REQUEST_URI} (.*)/install/?$
RewriteRule ^(.*)$ %1/install/index.php [NE,R,L]
# going to Admin folder
RewriteCond %{REQUEST_URI} (.*)/admin/?$
RewriteRule ^(.*)$ %1/Admin/index.php [NE,R,L]
# working with client side
RewriteRule ^(.*)/$ index.php?qstr=$1 [L]
</IfModule>
This is what I tried, which doesn't work:
RewriteCond %{HTTP_HOST} ^alennuskoodit.us [NC]
RewriteRule ^(.*)$ http://www.alennuskoodit.us/$1 [R=301,NC,L]
How could I redirect all queries to http://alennuskoodit.us to http://www.alennuskoodit.us so that I would not end up breaking the other rewrites?
Place your new rule before all the other rules i.e
Options +FollowSymLinks
Options +Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{HTTP_HOST} ^alennuskoodit.us$ [NC]
RewriteRule ^(.*)$ http://www.alennuskoodit.us/$1 [R=301,NC,L]
#other rules here
and it should prevent the qstr= param
Step1= You Must Use This Code In htaccess File To Preferred www Version:
RewriteCond %{HTTP_HOST} !^(.).YourDomain.com$ [NC] RewriteRule ^(.)$ http://www.YourDomain.com/$1 [R=301,L]
Step2= You Must Setting Your Preferred Domain In Google WebMaster Tools :
Open up your webmaster tools and click “Settings” right below “Configuration”. To the right look for the “Preferred Domain” and select which domain you prefer With www Or Not.

Resources