I am running ubuntu 18.04 with Apache version 2.4 and have one domain and two websites
domain : this.domain
website1 website.this.domain
website2 web-site.this.domain
i am trying to allow access to website1 ONLY if the link is clicked from website2 this means if you enter website.this.domain from your address bar it would redirect you to website2 otherwise if you came from website2 you will be able to access the page.
My .htaccess :
RewriteEngine on
RewriteBase /
RewriteCond ^{HTTP_REFERER} ^https://web-site.this.domain/
RewriteRule ^ - [L]
RewriteRule ^ https://web-site.this.domain [R,L]
The code blocks people from accessing directly and allows people that are coming from website2.
The issue is when people have access it doesn't load the page with all the data i tried to inspect it seems that its showing Network Error 0x80070005, Access is denied.
If i remove the rules everything is normal but it will be accessible from outside and inside.
So far i have tried also
<If %{HTTP_HOST} !='https://web-site.this.domain'">
Redirect / https://web-site.this.domain
</If>
The problem is it doesn't matter where the request is from (direct or through the link) it always redirects me to website2, I have also tried {HTTP_REFERER} still without any success.
Any help would be appreciated.
solution was :
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^web\-site\.this\.domain [NC]
RewriteRule ^ - [L,NC]
RewriteRule ^ - [F,NC]
User contributions licensed under CC BY-SA 3.0