In the daily work, two dogs is actually a hidden big touch, a brilliant sketch, many read small partners cry for sharing. In order to let more young fans see his work, Erdogzi developed a website that provides copyrighted sketches for download.
Two dog son’s small website, as long as the registered user can unlimited speed download sketch. This is originally a good thing, but with the increase in traffic, bandwidth cost became two dogs unbearable weight. Therefore, some friends suggested to make a VIP service, let THE VIP download at full speed, free users a little speed limit. Two dogs think this is a very good way, so open Baidu to find a specific way of operation.
If you need to limit the speed at which others can download from your site, use the Rewrite rule.
What is the Rewrite rule?
Rewrite is a server rewriting technique whose main function is to redirect urls. Its regular expressions are based on Perl. It can be both server-level (httpd.conf) and directory-level (.htaccess).
If you want to use the Rewrite module, you must first install or load it. There are two ways to do this: install the Rewrite module directly when you compile Apache; The other is to install Apache in DSO mode when you compile Apache and then use the source code and APXS to install the Rewrite module.
The above two methods of implementation, two dogs see confused, feel separate to each word can understand, connect and as if the book. Helpless two dog son try to ask for help omnipotent cloud customer service – Vivian little sister.
“Just plug into the Rewrite CDN and you can do it directly from the console.” Vivian little sister calm answer.
Boy! Worthy of being two dogs favorite and clap cloud, come to see the specific use of it.
Rewrite function overview again
The Rewrite function is designed to help users simplify the business logic of content distribution and improve the end user experience. Features rapid deployment and simple configuration, greatly reducing the cost of service implementation. At the same time, powerful, covering most of the Internet demand scenarios, including:
-
Through URL rewriting, you can beautify the WEBSITE URL and improve website SEO
-
To save more access bandwidth, limit the download speed of website requests
-
Controls the structure of the request URL, HTTP header fields, and so on
-
You can customize the error page of the source site to improve terminal user experience
-
Restrict the access behavior of specific clients and implement proper access control
In the use of the cloud also according to the needs of different users divided into two different ways of use:
-
General mode: This mode is suitable for users who have no development foundation and are not familiar with the grammar rules.
-
Programming mode: suitable for developers, compared with general mode, programming mode is more flexible, more powerful, suitable for users who have a deep understanding of grammar rules.
In order to make the universal model to meet the needs of more users. According to different use scenarios, paiyun is equipped with 7 functions for the general mode:
-
Add HTTP headers (including request and response headers)
-
Delete HTTP headers (including request and response headers)
-
Edge redirection
-
The URL rewrite
-
Request the speed limit
-
Access control
-
Custom error pages
Rewrite use case
Rewrite () : how to configure the speed limit? Vivian little sister told two dogs, general and programming two modes can be achieved, and step by step to personally demonstrate how to operate.
General mode:
Programming mode:
This rule indicates that when the URL matches the domain name, the rate limiting starts 1 KB after the file is loaded. The rate limiting value is 60 KB.
After the completion of the two dogs immediately tested, the Settings will take effect, immediately completed the speed limit.
Weiwei also told erguzi, in addition to the domain name speed limit, can also be specified type of file download speed limit, such as: specified zip file download speed limit.
Once this setting is complete, when the accessed URL matches the domain name and files with the suffix, the rate limiting starts.
Effect of conforming to restricted files:
Effects of other files:
Of course, can also be URL rewriting, for example: when accessing a URL need to rewrite into the end of the plus! Lalala parameters.
Recommended reading
These two completely different JPEG loading methods, you must have seen!
It is the behind-the-scenes hero that cannot be ignored in the era of short video.