Pseudo-Static is actually the use of PHP to resolve the current address to another method to access the site, to learn pseudo-static rules of the wording, to understand a little regular
First, regular expression tutorial
There is a classic tutorial: Regular expression 30-minute introductory tutorial
The common regular is as follows:
. All characters except line break
\w match letters or numbers or underscores or kanji
\s matches any whitespace character
\d Matching numbers
\b Match the beginning or end of a word
^ Start of matching string
$ match End of string
* Repeat 0 or more times
+ Repeat one or more times
? Repeat 0 or one time
{n} repeats n times
{n,} repeats n or more times
{N,m} repeats n to M times
When the substitution is applied, the match in the previous () is followed by a reference, and the second () matches the $ quote,,,,,
The thing inside this () is called the Atomic group.
Analysis of Discuz SEO htaccess inside the rewrite.
Rewriterule ^forum-([0-9]+)-([0-9]+) \.html$ forumdisplay.php?fid=$1&page=$2
First join the user through linuxidc.com/forum-2-3.html access to the Discuz forum, then first through the. htaccess filter to see if it is needed. htaccess Guide the user if the list of Rewritecond Condition then rewrite it,
Discuz is not listed Rewritecond so it should all be rewritten.
So we started the transliteration,
Forum-2-3.html this exactly matches the list of
^forum-([0-9]+)-([0-9]+) \.html$
The regular expression. and $2, $3,
So substituting the following, that is, forumdisplay.php?fid=2&page=3 plus the previous rewritebase specified file directory, then take him to the development of the directory forumdisplay.php?fid=2&page=3.
Ii. Common. htaccess application examples (some examples are quoted from four examples of actual combat.) htaccess file rewrite rules)
4.1 Prevent hotlinking, if come to access jpe jpg bmp png End of URL user is not from our site, then let him see a picture of our site display.
Rewriteengine Onrewritecond%{http_referer}!^http://(. +.)? mysite.com/[Nc]rewritecond%{http_referer}!^ $RewriteRule. *. (jpe?g|gif|bmp|png) $/images/nohotlink.jpg [L]
4.2 When the website is upgraded, only certain IP can be accessed, and other users will see an upgrade page
Rewriteengine Onrewritecond%{request_uri}!/upgrade.html$rewritecond%{remote_host}!^24\.121\.202\.30
Rewriterule $ http://www.linuxidc.com/upgrade.html [r=302,l]
4.3 Turn the old domain name to the new domain
# REDIRECT from old domain to new domainrewriteengine onrewriterule ^ (. *) $http://www.yourdomain.com/$1[r=301,l]
Iii. Common examples
Rewriteengine on
Rewriterule index.html index.php
For example: http://www.yzzmf.com/index.html-http://www.yzzmf.com/index.php
Rewriterule ^test ([0-9]*). html$ test.php?id=$1
For example: http://www.yzzmf.com/test8.html-http://www.yzzmf.com/test.php?id=8
Rewriterule ^cat-([0-9]+)-([0-9]+) \.html$ cat.php?id1=$1&id2=$2
For example: http://www.yzzmf.com/cat-1-3.html-http://www.yzzmf.com/cat.php?id1=1&id2=3
Rewriterule ^cat-([a-za-z0-9\-]*)-([0-9]+)-([0-9]+] \.html$ cat.php?id0=$1&id1=$2&id2=$3
For example: http://www.yzzmf.com/cat-zbc2ac-3-5.html-http://www.yzzmf.com/cat.php?id0=zbc2ac&id1=3&id2=5
Rewriterule ^cat1-([0-9]+)-([0-9]+)-([0-9]+] \.html$ cat1.php?id1=$1&id2=$2&id3=$3
For example: http://www.yzzmf.com/cat1-4-3-8.html-http://www.yzzmf.com/cat1.php?id1=4&id2=3&id3=8
Rewriterule ^cat ([0-9]*)/$ cat.php?id1=$1
For example: http://www.yzzmf.com/cat5/-http://www.yzzmf.com/cat.php?id1=5
Rewriterule ^CATM ([0-9]*)/([0-9]*)/$ catm.php?id1=$1&id2=$2
For example: http://www.yzzmf.com/catm6/3/-http://www.yzzmf.com/catm.php?id1=6&id2=3
It does not advocate greedy mode, the 0-9 is changed to ([\d]*?) *? allow null
Pseudo static rule notation rewriterule-htaccess verbose syntax usage