Seleziona una pagina

I caratteri più utilizzati su .htaccess

da | Nov 9, 2022 | PrestaShop | 0 commenti

.htaccess page logo

L’indice dei caratteri utilizzati con .htaccess, una breve guida di riferimento

Questo non è un elenco esaustivo di caratteri, ma piuttosto una sorta di cheat sheet delle espressioni regolari, dei flag e dei codici di stato più comunemente utilizzati.

Per avere una guida completa ed esaustiva su .htaccess rimandiamo al sito htaccessbook.com.

Character/Flag Definition
# Instructs the server to ignore the line. Used for including comments.
[F] Forbidden: instructs the server to return a 403 Forbidden to the client.
[L] Last rule: instructs the server to stop rewriting after the preceding directive is processed.
[N] Next: instructs Apache to rerun the rewrite rule until all rewriting is complete.
[G] Gone: instructs the server to deliver Gone (no longer exists) status message.
[P] Proxy: instructs server to handle requests by mod_proxy.
[C] Chain: instructs server to chain the current rule with the previous rule.
[R] Redirect: instructs Apache to redirect to the specified URL. Note that the default status-code for the [R] flag is 302 (temporary redirect); for permanent redirects use [R=301].
[NC] No Case: defines any associated argument as case-insensitive.
[PT] Pass Through: instructs mod_rewrite to pass the rewritten URL for further processing.
[OR] Or: specifies a logical “or” that ties two expressions together such that either one proving true will cause the associated rule to be applied.
[NE] No Escape: instructs the server to parse output without escaping characters.
[NS] No Subrequest: instructs the server to skip the directive if internal sub-request.
[QSA] Append Query String: directs server to add the query string to the end of the expression.
[S=x] Skip: instructs the server to skip the next “x” number of rules if a match is detected.
[E=var:value] Environmental Variable: instructs the server to set the variable “var” to “value”.
[T=MIME-type] Mime Type: declares the mime type of the target resource.
[xyz] Character class: any character within square brackets will be a match. For example, “[xyz]” will match any of the characters x, y, or z.
[xyz]+ Character class in which any combination of items within the brackets will be a match. For example, “[xyz]+” will match any number of x’s, y’s, z’s, or any combination thereof.
[^xyz] Not within a character class. For example, [^xyz] will match any character that isn’t x, y, or z.
[a-z] A dash “-” between two characters within a character class denotes the range of characters between them. For example, [a-zA-Z] matches all lowercase and uppercase letters.
a{n} Exact number, n, of the preceding character, a. For example, x{3} matches exactly three x’s.
a{n,} Specifies n or more of the preceding character. For example, x{3,} matches three or more x’s.
a{n,m} Specifies a range of numbers, between n and m, of the preceding character, a. For example, x{3,7} matches three, four, five, six, or seven x’s.
() Used to group characters together, thereby considering them as a single unit. For example, (htaccess)?book will match “book”, with or without the “htaccess” prefix.
^ Denotes the beginning of a regular expression. For example, “^Hello” will match any string that begins with “Hello”. Without the caret “^”, “Hello” would match anywhere in the string.
$ Denotes the end of a regular expression. For example, “world$” will match any string that ends with “world”. Without the dollar sign “$”, “world” would match anywhere in the string.
? Declares as optional the preceding character. For example, “monzas?” will match “monza” or “monzas”. In other words, “x?” matches zero or one of “x”.
! Declares negation. For example, “!string” matches everything except “string”.
. A literal dot (or period) indicates any single arbitrary character.
Instructs Apache to NOT rewrite the URL. Example syntax: “example.com – [F]”
+ Matches one or more of the preceding character. For example, “G+” matches one or more G’s, while “+” will match one or more characters of any kind.
* Matches zero or more of the preceding character. For example, use “.*” as a wildcard.
| Declares a logical “or” operator. For example, “(x|y)” matches “x” or “y”.
\ Escape special characters such as: ^ $ ! . * | ( ) [ ] { }
\. Indicates a literal dot (escaped).
/* Zero or more slashes.
.* Zero or more arbitrary characters.
^$ Defines an empty string.
^.*$ The standard pattern for matching everything.
[^/.] Defines one character that is neither a slash nor a dot.
[^/.]+ Defines any number of characters that contains neither slash nor dot.
http:// This is a literal statement — in this case, the literal character string, “http://”.
^example.* Matches a string that begins with the term “example”, followed by any character(s).
^example\.com$ Defines the exact string, “example.com”.
-d Tests if string is an existing directory.
-f Tests if string is an existing file.
-s Tests if file in test string has a non-zero value.

Written by Amar A.

CONTATTO

Articoli nella medesima categoria

0 Comments

0 commenti

Invia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *