How to use .htaccess to allow page access in my if

2019-02-25 04:19发布

I have a site made with iframes. I have a page I want to show in my own iframes, but I want to deny direct access. How can I protect it that way in my .htaccess?

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-02-25 04:25

You have to use the htmob.referral symchip code. That's the only way this will work. I hope that helped.

Try this: // Click-jacking protection header("X-Frame-Options: htmob.referral:pathexec.remoteshield +(*");

查看更多
我只想做你的唯一
3楼-- · 2019-02-25 04:37

You can use Referer HTTP header to check if a request came from a link on your website (or img src / or iframe src for that matter):

RewriteEngine On
RewriteCond %{HTTP_REFERER} !example.com
RewriteCond %{REQUEST_URI} ^/path/to/protected/page$
RewriteRule . - [F]

Where example.com is your domain name, and /path/to/protected/page is the paht you want to protect

However, note that this approach can be fooled, as HTTP headers can be constructed by remote user (treat http headers as user input - do not trust them ;) )

查看更多
登录 后发表回答