Friends who have been exposed to .htaccess files may not understand some of the syntax on the opposite side. You will often see a rule followed by some capital letters L NC R QSA or something like that. Do you know what they mean? OK, the following article is a brief explanation of the relevant syntax parameters of the .htaccess file.
chain|C (link next rule)
This tag links the current rule to the next rule. It has the effect that if a rule is matched, its successor rules will continue to be processed, that is, this tag will have no effect; if the rule is not matched, its successor rules will be skipped. For example, when performing an external redirect in a directory-level rule, you may need to remove ".www" (".www" should not appear here).
cookie|CO=NAME:VAL:domain[:lifetime[:path]](set cookie)
Set a cookie on the client side. The name of the cookie is NAME and the value is VAL. domain is the domain of the cookie, such as .apache.org, optional lifetime is the validity period of the cookie (minutes), and optional path is the path of the cookie.
env|E=VAR:VAL (set environment variable)
This tag sets the value of the environment variable VAR to VAL. VAL can contain expandable regular expression backreferences ($N and %N). This tag can be used multiple times to set multiple variables. These variables can be indirectly referenced in many subsequent situations, usually in XSSI () or CGI ($ENV{VAR}), or in subsequent RewriteCond Referenced through %{ENV:VAR} in the CondPattern parameter of the instruction. Use this to remember information stripped from the URL.
forbidden|F (forbidden URL)
Forcibly ban the current URL, that is, immediately feedback an HTTP response code 403 (forbidden). Using this tag, you can chain several RewriteConds to conditionally block certain URLs.
gone|G (forced abandonment of URL)
Forcing the current URL to be obsolete, that is, immediately feedback an HTTP response code 410 (obsolete). Use this tag to indicate that the page has been abandoned and no longer exists.
handler|H=Content-handler (mandatory content handler specification)
Strongly customize the content handler of the target file as Content-handler. For example, the ScriptAlias directive is used to emulate the mod_alias module to force all files within the mapped folder to be processed by the "cgi-script" processor.
last|L (ending rule)
Stop the rewrite operation immediately and no other rewrite rules will be applied. It corresponds to the last command in Perl or the break command in C language. This tag is used to prevent the currently rewritten URL from being rewritten again by subsequent rules. For example, you can use it to rewrite the URL of the root path (/) to an actual URL (for example: /e/www/).
next|N(start over)
Re-execute the rewrite operation (starting over from the first rule). At this time, the URL processed again is no longer the original URL, but the URL processed by the last rewriting rule. It corresponds to the next command in Perl or the continue command in C language. This mark allows the rewrite operation to be restarted (immediately back to the beginning of the loop). But be careful not to create an infinite loop!
nocase|NC(ignore case)
It makes Pattern ignore case, that is, when Pattern matches the current URL, there is no difference between A-Z and a-z.
noescape|NE (Do not escape URIs in output)
This tag prevents mod_rewrite from applying normal URI escaping rules to the rewrite results. Under normal circumstances, special characters (%, $, ;, etc.) will be escaped to the equivalent hexadecimal encoding (%25′, %24′, %3B, etc.). This flag prevents such escaping to allow symbols such as percent signs to appear in the output, such as:
RewriteRule /foo/(.*) /bar?arg=P1%3d$1 [R,NE] can redirect /foo/zed to a safe request /bar?arg=P1=zed
nosubreq|NS (internal subrequests are not processed)
This tag forces the rewrite engine to skip the rewrite rule when the current request is an internal subrequest. For example, when mod_include attempts to search the directory default file (index.xxx), Apache will generate a subrequest internally. Rewriting rules is not necessarily useful for subrequests, and it may even throw an error if the entire ruleset is in effect. Therefore, you can use this tag to exclude certain rules. Usage principle: If you add a CGI script prefix to URLs to force them to be processed by CGI scripts, but the error rate (or resource overhead) of subrequest processing is high, in this case, you can use this tag.
proxy|P (forced to be a proxy)
This flag causes the replacement component to be internally forced to be sent as a proxy request, immediately interrupting rewrite processing and handing over processing to the mod_proxy module. You must ensure that this replacement string is a valid URI that can be processed by mod_proxy (such as starting with http://www.phpernote.com), otherwise you will get an error returned by the proxy module. Using this tag, certain remote components can be mapped to the local server domain name space, thereby enhancing the functionality of the ProxyPass directive. Note: To use this feature, the mod_proxy module must be enabled.
passthrough|PT (hand over to next processor)
This tag forces the rewrite engine to set the uri field in the internal request_rec structure to the value of the filename field. This small modification enables the output of the RewriteRule directive to be converted from URI to filename by Alias, ScriptAlias, Redirect Wait for instructions for post-processing [Original text: This flag is just a hack to enable post-processing of the output of RewriteRule directives, using Alias, ScriptAlias, Redirect, and other directives from various URI-to-filename translators.].
Give an example to illustrate its meaning: If you want to rewrite /abc to /def, and then use mod_alias to convert /def to /ghi, you can do this:
RewriteRule ^/abc(.*) /def$1 [PT]
Alias /def /ghi
If the PT tag is omitted, although the part that rewrites uri=/abc/… to filename=/def/… works fine, subsequent mod_alias will encounter failures when trying to convert the URI to a file name. Note: This tag must be used if you need to mix multiple modules that convert URIs to file names. . Mixing mod_alias and mod_rewrite here is a typical example.
qsappend|QSA(append query string)
This tag forces the rewrite engine to append a query string to the existing replacement string instead of simply replacing it. You can use this tag if you need to add information to the request string through rewriting rules.
redirect|R [=code](force redirect)
If the Substitution starts with http://thishost[:thisport]/ (making the new URL a URI), an external redirect can be forced. If no code is specified, an HTTP response code 302 (Temporary Move) is generated. If you need to use another response code in the range 300-400, just specify it here (or use one of the following symbolic names: temp (default), permanent, seeother). Use it to feed back the normalized URL to the client, such as rewriting "/~" to "/u/", or always adding a slash to /u/user, etc.
Note: When using this tag, you must ensure that the replacement field is a valid URL. Otherwise, it would point to an invalid location! And remember that this tag itself just prefixes the URL with http://thishost[:thisport]/, the rewriting operation will still proceed. Usually, you will also want to stop the rewriting operation and redirect immediately, so you will also need to use the L flag.
skip|S=num (skip subsequent rules)
This tag forces the rewrite engine to skip num rules after the current matching rule. It can simulate an if-then-else structure: the last rule is a then clause, and the skip=N rules are else clauses. Note: It is different from the chain|C tag!
type|T=MIME-type (mandatory MIME type)
Forcing the MIME type of the target file to be MIME-type, which can be used to force the content type based on certain conditions. For example, the following command allows .php files to be displayed by mod_php according to the MIME type of the PHP source code (application/x-httpd-php-source) when called with the .phps extension:
RewriteRule ^(.+.php)s$ $1 [T=application/x-httpd-php-source]
Articles you may be interested in
- phpMyAdmin Cannot start session without errors error solution
- .htaccess How to set up anti-hotlinking for pictures in a directory
- Usage of several keywords such as $this, static, final, const, self, etc. in php
- Use .htaccess ban list directory
- Fatal error Class 'SoapClient' not found in...Error handling method
- php prompts Maximum execution time of 30 seconds exceeded... Solutions to errors
- 10 practical .htaccess code snippets
- Use .htaccess to deny certain IP access to the website

提到API开发,你可能会想到DjangoRESTFramework,Flask,FastAPI,没错,它们完全可以用来编写API,不过,今天分享的这个框架可以让你更快把现有的函数转化为API,它就是Sanic。Sanic简介Sanic[1],是Python3.7+Web服务器和Web框架,旨在提高性能。它允许使用Python3.5中添加的async/await语法,这可以有效避免阻塞从而达到提升响应速度的目的。Sanic致力于提供一种简单且快速,集创建和启动于一体的方法

随着PHP8.0的发布,新增了一种类型别名语法,使得使用自定义的类型变得更加容易。在本文中,我们将深入了解这种新的语法,以及它对开发人员的影响。什么是类型别名?在PHP中,类型别名本质上是一个变量,它引用另一个类型的名称。这个变量可以像其他类型一样使用,并在代码中的任何地方声明。这种语法的主要作用是为常用的类型定义自定义别名,使得代码更加易于阅读和理解。

ML中的一个重要任务是模型选择,或者使用数据为给定任务找到最佳的模型或参数。这也称为调优。可以对单个的估计器(如LogisticRegression)进行调优,也可以对包括多种算法、特性化和其他步骤的整个pipeline进行调优。用户可以一次调优整个Pipeline,而不是分别调优 Pipeline 中的每个元素。ML中的一个重要任务是模型选择,或者使用数据为给定任务找到最佳的模型或参数。这也称为调优。可以对单个的Estimator(如LogisticRegression)进行调优,也

Lambda表达式是无名称的匿名函数,其语法为:(parameter_list)->expression。它们具有匿名性、多样性、柯里化和闭包等特点。实际应用中,Lambda表达式可用于简洁地定义函数,如求和函数sum_lambda=lambdax,y:x+y,并通过map()函数应用于列表来进行求和操作。

Go语言与JS的联系与区别Go语言(也称为Golang)和JavaScript(JS)都是当前流行的编程语言,它们在某些方面有联系,在其他方面又有明显的区别。本篇文章将探讨Go语言与JavaScript之间的联系与区别,同时提供具体的代码示例来帮助读者更好地理解这两种编程语言。联系:都是跨平台的Go语言和JavaScript都是跨平台的,可以在不同的操作系统

PHP是一种广泛应用于Web开发的服务器端脚本语言,而PHP8.0版本中引入了一种新的父类调用语法,让面向对象编程更加方便和简洁。在PHP中,我们可以通过继承的方式创建一个父类和一个或多个子类。子类可以继承父类的属性和方法,并可以通过重写父类的方法来修改或扩展其功能。在普通的PHP继承中,如果我们想在子类中调用父类的方法,需要使用parent关键字来引用父

掌握基本的CSS选择器语法,需要具体代码示例CSS选择器是前端开发中非常重要的一部分,它可以用来选择和修改HTML文档的各个元素。掌握基本的CSS选择器语法对于编写高效的样式表是至关重要的。本文将介绍一些常见的CSS选择器以及对应的代码示例。元素选择器元素选择器是最基本的选择器,可以通过元素的标签名来选择对应的元素。例如,要选择所有的段落(p元素),可以使用

C语言中乘方运算的语法和用法简介:在C语言中,乘方运算(poweroperation)是一种常见的数学运算,它用于计算一个数的幂。在C语言中,我们可以使用标准库函数或者自定义函数来实现乘方运算。本文将详细介绍C语言中乘方运算的语法和用法,并提供具体的代码示例。一、使用math.h中的pow()函数在C语言中,math.h标准库中提供了pow()函数,用于执


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)