8

Outside of daily work, Ergouzi is actually a hidden touch. One-hand sketches are supernatural, and many friends who have seen it scream for sharing. In order to allow more young fans to see his work, Ergouzi has developed a download site that provides copyrighted sketches.

Ergouzi’s small website, as long as it is a registered user, you can download sketches at unlimited speed. This was originally a good thing, but with the increase in traffic, the cost of bandwidth has become an unbearable burden for Ergouzi. So a small partner suggested to create a VIP service, allowing VIP to download at full speed, and free users with a little speed limit. Er Gouzi thought this was a good way, so he opened Baidu to find out how to do it.

Baidu said that some traditional settings are set locally to limit the download speed. If you need to limit the download speed of others from your website, you need to use the Rewrite rule.

What are the Rewrite rules?

Rewrite is a server rewriting technology. Its main function is to realize URL jump. Its regular expression is based on Perl language. It can be based on server-level (httpd.conf) and directory-level (.htaccess) two ways.

If you want to use the Rewrite module, you must first install or load the Rewrite module. There are two methods: one is to install the Rewrite module directly when compiling apache; the other is to install apache in DSO mode when compiling apache, and then use the source code and apxs to install the Rewrite module.

With the above two implementation methods, Er Gouzi was confused, feeling that every word can be understood separately, and they are like a heavenly book when they are connected. The helpless Ergouzi tried to ask for help from the omnipotent cloud customer service-Miss Weiwei.

"You can directly use the Rewrite function when you connect to the CDN and you can directly operate on the console, which is very convenient." Miss Weiwei answered calmly.

Good guys! As expected of Ergouzi's favorite and Paiyun, come and see how to use it.

Rewrite function overview

The Rewrite function of Yupaiyun is mainly to help users simplify the content distribution business logic and improve the end user's access experience. The feature is that it can be deployed quickly and configured simply, which can greatly reduce the cost of business implementation. At the same time, it has powerful functions, covering most of the Internet demand scenarios, including:

  • URL rewriting can beautify website URL and improve website SEO
  • In order to save more access bandwidth, limit the download speed of website requests
  • Control the structure of the request URL, HTTP headers, etc.
  • Customize the error page of the origin site to improve the end user experience
  • Restrict the access behavior of specific clients and conduct reasonable access control

In use, Youpaiyun also divides two different ways of use according to different user needs:

  • General mode: It is suitable for users who have no development foundation and are not familiar with grammatical rules. This mode is convenient and quick to use.
  • Programming mode: It is suitable for developers. Compared with the general mode, the programming mode will be more flexible and more powerful. It is suitable for users who have an in-depth understanding of grammar rules.

In order to make the universal mode meet the needs of more users. According to different usage scenarios, PAIYUN is equipped with 7 major functions for [General Mode]:

  • Add HTTP headers (including request headers and response headers)
  • Delete HTTP headers (including request headers and response headers)
  • Edge redirection
  • URL rewriting
  • Request rate limit
  • Access control
  • Custom error page

Rewrite use cases

After reading the introduction of the cloud Rewrite function, Ergouzi configures the download speed limit. What should I do? Miss Weiwei told Ergouzi that it can be implemented in both general and programming modes, and demonstrates how to operate it step by step.

General mode:

Programming mode:

This rule indicates that when the accessed URL matches this domain name, the speed limit will start after the file is loaded 1k, and the speed limit value is: 60k.

Ergouzi immediately tested it after the setting was completed, the setting took effect, and the speed limit was immediately completed.

Weiwei also told Ergouzi that in addition to the domain name speed limit, the download speed limit can also be imposed on the specified type of file, such as the download speed limit of the specified zip file.

After completing this setting, when the accessed URL matches this domain name, and files that match this suffix, the speed limit will begin.

Comply with the effect of restricted files:

Effects of other files:

Of course, the URL can also be rewritten. For example, when accessing a URL, it needs to be rewritten to add the !lalala parameter at the end.

Recommended reading

These two completely different JPEG loading methods, you must have seen them!

It is the hero behind the scenes that cannot be ignored in the short video era!


云叔_又拍云
5.9k 声望4.6k 粉丝

又拍云是专注CDN、云存储、小程序开发方案、 短视频开发方案、DDoS高防等产品的国内知名企业级云服务商。