简体   繁体   中英

Single File Access by certain domains

I was wondering if there is an “easy” way to protect a file from begin access from all domains…

Let say that I want only a few domains to use my script so they put in their HTML From domain yourdomain.com you write

If your domain is in our “allow” access then you can use it, if not, then show an error or just nothing…

Is that possible with PHP?

Or do I have to use .htaccess ?

Probably the most straight forward way is to use a .htaccess file. These files typically take IP address and not domains. The code below would only allow from 1.1.1.1 and 2.2.2.2 and anything else would be denied.

<Limit GET POST>
 order deny,allow
 deny from all
 allow from 1.1.1.1
 allow from 2.2.2.2
</Limit>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM