About PHP pseudo-static rewrite settings, PHP pseudo-rewrite
The main function of Rewirte is to achieve URL to jump and hide real address, a regular expression specification based on the Perl language. Usually help us achieve quasi-static, quasi-directory, domain name jump, prevent hotlinking, etc.
First, Apache
Configuration:1, Support httpd.conf configuration 2, Support directory. htaccess configuration (a "Distributed Configuration" file for virtual space, the space quotient does not allow the modification of the Apache configuration file)
enable rewrite (httpd.conf) (sometimes the options Indexes followsymlinks will go wrong, just configure the options all)LoadModule Rewrite_module modules/mod_rewrite.so
Enable. htaccessAllowOverride None modified to: allowoverride all
Second, mod_rewrite
Rules:Example: Rewriteengine on
-
Start
rewrite
engineRewriterule ^/test ([0-9]*). html$/test.php?id=$1
---Access test plus any field. html can jump to test.php regular matching fields stored in virtual memory match $
Third, Mod_rewrite
rules
modifier1) R Force external redirect 2) F disable URL, return 403HTTP status code. 3) G force URL is gone, return 410HTTP status code. 4) P forces the use of proxy forwarding. 5) L indicates that the current rule is the last rule, which stops the rewrite of the rule after parsing. 6) N re-run the rewrite process starting with the first rule. 7) C is associated with the next rule
If rule matching is handled correctly, the following modifier is invalid8) T=mime-type (Force MIME type) enforces MIME type 9) NS only for not internal sub-requests (NC) is case-insensitive) QSA append request string () NE not output escape special character \%3d$1 equivalent to =$1 example Such as:
Rewriterule ^/
New
([0-9]*)/
$ /
New
. php?id=$1
[R]Simple Small Example:
^/in (. *). html$/index.php
Easy to implement ~
Apache configuration rewrite problem php| pseudo-static | Rewriterule
Rewriteengine on
Rewriterule ^ (. *)/classlist/(. *) $ $1/class_list.php?type=$2
</IfModule>
Virtual host is a Linux system, the operating environment of the website program is php+mysql, how to set pseudo-static??
Hello, this has to be based on your website program and Web server environment to set pseudo-static, such as you use the LNMP environment, and the PHP program is DZ2.5 then your pseudo-static can be:
rewrite ^ ([^\.] *)/topic-(. +) \.html$ $1/portal.php?mod=topic&topic=$2last;
rewrite ^ ([^\.] *)/article-([0-9]+)-([0-9]+) \.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^ ([^\.] *)/forum-(\w+)-([0-9]+) \.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^ ([^\.] *)/thread-([0-9]+)-([0-9]+)-([0-9]+] \.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3d$4&page =$3 last;
rewrite ^ ([^\.] *)/group-([0-9]+)-([0-9]+) \.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^ ([^\.] *)/space-(USERNAME|UID)-(. +) \.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^ ([^\.] *)/blog-([0-9]+)-([0-9]+) \.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^ ([^\.] *)/(Fid|tid)-([0-9]+) \.html$ $1/index.php?action=$2&value=$3 last;
rewrite ^ ([^\.] *)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+) \.html$ $1/plugin.php?id=$2:$3 last;
if (!-e $request _filename) {
return 404;
}
There are problems can +q+ group 222802357 to find a group of owners.
http://www.bkjia.com/PHPjc/852743.html www.bkjia.com true http://www.bkjia.com/PHPjc/852743.html techarticle about PHP pseudo-static rewrite settings, the main function of PHP pseudo-rewrite Rewirte is to implement the URL of the jump and hide the real address, based on the Perl language regular expression specification. Usually help us ...