In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "what is the use of RewriteCond rule parameters in Apache", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "what is the use of RewriteCond rule parameters in Apache" this article.
RewriteCond is like the if statement in our program, which means that if one or more conditions are met, the RewriteRule statement next to RewriteCond will be executed. This is the most primitive and basic function of RewriteCond. For ease of understanding, let's take a look at a few examples.
The code is as follows:
RewriteEngine on
RewriteCond% {HTTP_USER_AGENT} ^ Mozilla//5/.0.*
RewriteRule index.php index.m.php
RewriteCond% {HTTP_USER_AGENT} ^ Lynx.*
RewriteRule index.php index.L.php
RewriteRule index.php index.b.php
The role of the above statement is that when you are using a FF browser to access the index.php file, it will automatically allow you to access the index.m.php file, when you are using some mobile terminal access, the actual access to the index.php file will be index.L.php, and if you are using other browsers, it will allow you to skip to index.b.php. To put it figuratively, the above statement is equivalent to the following statement in the program (take the PHP statement as an example):
The code is as follows:
If ($_ SERVER ['HTTP_USER_AGENT'] = =' Mozilla/5.0')
{
/ / Jump to access index.m.php
}
Else if ($_ SERVER ['HTTP_USER_AGENT'] = =' Lynx')
{
/ / Jump to access index.L.php
}
Else
/ / Jump to access index.b.php
Let's look at example 2:
RewriteCond% {HTTP_REFERER} (www.test.cn)
RewriteRule (. *) $test.php
The effect of the above statement is that if the host address of the last page you visited is www.test.cn, no matter which page you are currently visiting, you will jump to test.php access.
Let's look at example 3:
The code is as follows:
RewriteCond% {REMOTE_HOST} ^ host1.* [OR]
RewriteCond% {REMOTE_HOST} ^ host2.* [OR]
RewriteCond% {REMOTE_HOST} ^ host3.*
RewriteRule (. *) $test.php
The purpose of the above statement is to skip to test.php if your address is host1 or host2 or host3. As you can see here, the default between RewriteCond statements is AND, and if you want to OR, write it explicitly.
Here are some useful rewriting rules from your collection:
RewriteCond% {REQUEST_FILENAME}!-f / / if the file exists, access the file directly without the following RewriteRule. (rewrite is not performed if the file or file does not exist)
RewriteCond% {REQUEST_FILENAME}!-d / / # if the directory exists, access the directory directly without RewriteRule
RewriteCond% {REQUEST_URI}! ^. * (/ .css | / .js | / .gif | / .png | / .jpg | / .jpeg) $/ / # if it is a file with these suffixes, access the file directly without Rewrite
The above is all the content of the article "what is the use of RewriteCond rule parameters in Apache". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.