Home Backend Development PHP Tutorial Solution to using Apache's htaccess to prevent images from being linked_PHP Tutorial

Solution to using Apache's htaccess to prevent images from being linked_PHP Tutorial

Jul 21, 2016 pm 03:11 PM
apache htaccess one code use Order picture copy method of solve chain prevent

Method 1:
The required commands are as follows:

Copy the code The code is as follows:

RewriteEngine on

RewriteCond %{ HTTP_REFERER } !^$

RewriteCond %{ HTTP_REFERER } !^http://(www.)?simue.com /.*$ [NC ]

RewriteRule .(gif &line;jpg)$ - [F]

If you think it doesn’t look good to have a skylight open on someone else’s page, you can use a picture Instead:

View code
Copy code The code is as follows:

RewriteEngine on

RewriteCond %{ HTTP_REFERER } !^$

RewriteCond %{ HTTP_REFERER } !^http://(www.)?simue.com/.*$ [NC]

RewriteRule .(gif &line;jpg)$ http://www.simue.com /Replacement image file name [R,L]
It should be noted that if the created .htaccess is uploaded to the server through FTP , the transmission mode should be ASCII instead of Binary. After uploading to the server, its attributes should be modified to 644 or "RW-R–R–" through CHMOD. In this way, it can be ensured that the server can be used and cannot be modified through the browser. Of course, there are also certain issues with the readable attributes of .htaccess. Risk: This could allow an attacker to figure out what you want to protect or the location of the authentication file - the solution is to place the authentication file .htpasswd outside the root of the website so it cannot be found over the network.

Method 2:
Copy the code The code is as follows:

View code 01 RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$ [NC]

RewriteCond %{HTTP_REFERER} !simue.com [NC]

RewriteCond %{HTTP_REFERER } !baidu.com [NC]

RewriteCond %{HTTP_REFERER} !google.com [NC]

RewriteRule .*.(gif|jpg)$ http://www.simue. com /no.png [R,NC,L]

Briefly explain the above statement:
1. RewriteCond %{HTTP_REFERER} !^$ [NC]

Allow access to empty "HTTP_REFERER", which allows the display of image files when the user directly enters the image address in the browser address bar. Generally speaking, this is optional, but it is recommended to set it this way. If it is forced to have "HTTP_REFERER" to access, it may cause certain problems, such as when users access through a proxy server.

2. RewriteCond %{HTTP_REFERER} !simue.com [NC]

Set the HTTP sources allowed to be accessed, including our website itself, Google, Baidu, etc.

3. RewriteRule .*.(gif|jpg|png)$ http://www.simue.com/no.png [R,NC,L]

Define the image to be replaced when hotlinked, so that all webpages with jpg, gif, png and other files that are hotlinked will display the no.png file in the root directory. Note: Do not place the replaced image in the directory where anti-hotlinking is set, and the smaller the file size of the image, the better. Of course, you can also use the following statement instead of setting a replacement image:

RewriteRule .*.(gif|jpg|png)$ - [F]

4. Explain R, NC and L

R means turn
NC means not case sensitive
L is used to indicate that this turn ends here, and subsequent turns will not be affected by the previous judgment statement

5. File types to prevent hotlinking

In the above example, they are gif, jpg, and png. If necessary, you can change or add other file types, such as rar, swf, etc. Use "|" to separate different file extensions.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326960.htmlTechArticleMethod 1: The required commands are as follows: Copy the code as follows: RewriteEngine on RewriteCond %{ HTTP_REFERER } !^$ RewriteCond %{ HTTP_REFERER } !^http://(www.)?simue.com /.*$...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The secret of hatching mobile dragon eggs is revealed (step by step to teach you how to successfully hatch mobile dragon eggs) The secret of hatching mobile dragon eggs is revealed (step by step to teach you how to successfully hatch mobile dragon eggs) May 04, 2024 pm 06:01 PM

Mobile games have become an integral part of people's lives with the development of technology. It has attracted the attention of many players with its cute dragon egg image and interesting hatching process, and one of the games that has attracted much attention is the mobile version of Dragon Egg. To help players better cultivate and grow their own dragons in the game, this article will introduce to you how to hatch dragon eggs in the mobile version. 1. Choose the appropriate type of dragon egg. Players need to carefully choose the type of dragon egg that they like and suit themselves, based on the different types of dragon egg attributes and abilities provided in the game. 2. Upgrade the level of the incubation machine. Players need to improve the level of the incubation machine by completing tasks and collecting props. The level of the incubation machine determines the hatching speed and hatching success rate. 3. Collect the resources required for hatching. Players need to be in the game

How to set font size on mobile phone (easily adjust font size on mobile phone) How to set font size on mobile phone (easily adjust font size on mobile phone) May 07, 2024 pm 03:34 PM

Setting font size has become an important personalization requirement as mobile phones become an important tool in people's daily lives. In order to meet the needs of different users, this article will introduce how to improve the mobile phone use experience and adjust the font size of the mobile phone through simple operations. Why do you need to adjust the font size of your mobile phone - Adjusting the font size can make the text clearer and easier to read - Suitable for the reading needs of users of different ages - Convenient for users with poor vision to use the font size setting function of the mobile phone system - How to enter the system settings interface - In Find and enter the "Display" option in the settings interface - find the "Font Size" option and adjust it. Adjust the font size with a third-party application - download and install an application that supports font size adjustment - open the application and enter the relevant settings interface - according to the individual

How to choose a mobile phone screen protector to protect your mobile phone screen (several key points and tips for purchasing mobile phone screen protectors) How to choose a mobile phone screen protector to protect your mobile phone screen (several key points and tips for purchasing mobile phone screen protectors) May 07, 2024 pm 05:55 PM

Mobile phone film has become one of the indispensable accessories with the popularity of smartphones. To extend its service life, choose a suitable mobile phone film to protect the mobile phone screen. To help readers choose the most suitable mobile phone film for themselves, this article will introduce several key points and techniques for purchasing mobile phone film. Understand the materials and types of mobile phone films: PET film, TPU, etc. Mobile phone films are made of a variety of materials, including tempered glass. PET film is relatively soft, tempered glass film has good scratch resistance, and TPU has good shock-proof performance. It can be decided based on personal preference and needs when choosing. Consider the degree of screen protection. Different types of mobile phone films have different degrees of screen protection. PET film mainly plays an anti-scratch role, while tempered glass film has better drop resistance. You can choose to have better

Tsinghua University and Zhipu AI open source GLM-4: launching a new revolution in natural language processing Tsinghua University and Zhipu AI open source GLM-4: launching a new revolution in natural language processing Jun 12, 2024 pm 08:38 PM

Since the launch of ChatGLM-6B on March 14, 2023, the GLM series models have received widespread attention and recognition. Especially after ChatGLM3-6B was open sourced, developers are full of expectations for the fourth-generation model launched by Zhipu AI. This expectation has finally been fully satisfied with the release of GLM-4-9B. The birth of GLM-4-9B In order to give small models (10B and below) more powerful capabilities, the GLM technical team launched this new fourth-generation GLM series open source model: GLM-4-9B after nearly half a year of exploration. This model greatly compresses the model size while ensuring accuracy, and has faster inference speed and higher efficiency. The GLM technical team’s exploration has not

Application of algorithms in the construction of 58 portrait platform Application of algorithms in the construction of 58 portrait platform May 09, 2024 am 09:01 AM

1. Background of the Construction of 58 Portraits Platform First of all, I would like to share with you the background of the construction of the 58 Portrait Platform. 1. The traditional thinking of the traditional profiling platform is no longer enough. Building a user profiling platform relies on data warehouse modeling capabilities to integrate data from multiple business lines to build accurate user portraits; it also requires data mining to understand user behavior, interests and needs, and provide algorithms. side capabilities; finally, it also needs to have data platform capabilities to efficiently store, query and share user profile data and provide profile services. The main difference between a self-built business profiling platform and a middle-office profiling platform is that the self-built profiling platform serves a single business line and can be customized on demand; the mid-office platform serves multiple business lines, has complex modeling, and provides more general capabilities. 2.58 User portraits of the background of Zhongtai portrait construction

How to conduct concurrency testing and debugging in Java concurrent programming? How to conduct concurrency testing and debugging in Java concurrent programming? May 09, 2024 am 09:33 AM

Concurrency testing and debugging Concurrency testing and debugging in Java concurrent programming are crucial and the following techniques are available: Concurrency testing: Unit testing: Isolate and test a single concurrent task. Integration testing: testing the interaction between multiple concurrent tasks. Load testing: Evaluate an application's performance and scalability under heavy load. Concurrency Debugging: Breakpoints: Pause thread execution and inspect variables or execute code. Logging: Record thread events and status. Stack trace: Identify the source of the exception. Visualization tools: Monitor thread activity and resource usage.

How to add a server in eclipse How to add a server in eclipse May 05, 2024 pm 07:27 PM

To add a server to Eclipse, follow these steps: Create a server runtime environment Configure the server Create a server instance Select the server runtime environment Configure the server instance Start the server deployment project

What is Bitget Launchpool? How to use Bitget Launchpool? What is Bitget Launchpool? How to use Bitget Launchpool? Jun 07, 2024 pm 12:06 PM

BitgetLaunchpool is a dynamic platform designed for all cryptocurrency enthusiasts. BitgetLaunchpool stands out with its unique offering. Here, you can stake your tokens to unlock more rewards, including airdrops, high returns, and a generous prize pool exclusive to early participants. What is BitgetLaunchpool? BitgetLaunchpool is a cryptocurrency platform where tokens can be staked and earned with user-friendly terms and conditions. By investing BGB or other tokens in Launchpool, users have the opportunity to receive free airdrops, earnings and participate in generous bonus pools. The income from pledged assets is calculated within T+1 hours, and the rewards are based on

See all articles