1 Open Apache’s configuration file httpd.conf.
Second, remove the # in front of #LoadModule rewrite_module modules/mod_rewrite
Third, add in httpd.conf:
RewriteEngine On
#RewriteCond %{ENV:SCRIPT_URL} (?:index|dispbbs)[ -0-9]+.html
RewriteRule ^(.*?(?:index|dispbbs))-([-0-9]+).html$ $1.php?__is_apache_rewrite=1&__rewrite_arg=$2
Fourth: To implement the mapping of asp post URL to php post, add between
RewriteMap tolowercase int:tolower
RewriteCond %{QUERY_STRING} ( ?:boardid|page|id|replyid|star|skin)=d+ [NC]
RewriteRule ^(.*(?:index|dispbbs)).asp$ $1.php?${tolowercase:%{QUERY_STRING}}&__is_apache_rewrite =1
5 Save httpd.conf and restart Apache.
6. Introduction to mod_rewrite
The main function of Rewirte is to realize URL jump and hide the real address, based on the regular expression specification of Perl language. We usually help us achieve pseudo-static, pseudo-directory, domain name jump, prevent hot links, etc.
7. Use of mod_rewrite rules
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.php100.com [NC]
RewriteRule ^/( .*) http://www.php100.com/ [L]
--------
RewriteEngine on
RewriteRule ^/test([0-9]*).html$ /test.php?id =$1
RewriteRule ^/new([0-9]*)/$ /new.php?id=$1 [R]
8. mod_rewrite rule modifier
1) R forces external redirection
2) F disables URL, Returns 403 HTTP status code.
3) G forces the URL to be GONE and returns 410 HTTP status code.
4) P forces the use of proxy forwarding.
5) L indicates that the current rule is the last rule and stops analyzing the rewriting of future rules.
6) N Run the rewrite process starting from the first rule again.
7) C is associated with the next rule 8) T=MIME-type (force MIME type) forces MIME type
9) NS is only used for non-internal subrequests
10) NC is not case sensitive
11) QSA appends request characters String
12) NE does not output escaped special characters %3d$1 is equivalent to =$1
The above introduces the pseudo-static configuration and use in apache, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.