PHP Pseudo static Rewrite Setting APACHE
- 2021-07-10 18:58:14
1. Apache configuration:
1. Support httpd. conf configuration
2. Support directory. htaccess configuration (1 kind of "distributed configuration" file is for virtual space, and space vendors are not allowed to modify Apache configuration file)
Enable Rewrite (httpd. conf)
(Sometimes Options Indexes FollowSymLinks will go wrong, just configure Options all.)
LoadModule rewrite_module modules/mod_rewrite.so
AllowOverride None is amended as: AllowOverride All
2. mod_rewrite rule:
RewriteEngine on -> Start rewrite Engine RewriteRule ^/test([0-9]*).html$ /test.php?id=$1 -> Refers to access test Add any field .html Can jump to test.php Regular matching fields are stored in virtual memory to match $1
3. mod_rewrite rule modifier
1) R Force External Redirection
2) F Disable URL and return 403HTTP status code.
3) G forces URL to GONE and returns 410HTTP status code.
4) P forces proxy forwarding.
5) L indicates that the current rule is the last rule, and stops analyzing the rewriting of subsequent rules.
6) N restarts the rewrite process from Rule 1.
7) C is associated with the following rule
If the rule matches, it will be processed normally, and the following modifiers are invalid
8) T=MIME-type (force MIME type) Forced MIME type
9) NS is only used for sub-requests that are not internal
10) NC is not case sensitive
11) QSA append request string
12) NE not outputting escape special character\% 3d $1 is equivalent to = $1
RewriteRule ^/new([0-9]*)/$ /new.php?id=$1 [R]
Simple small example:
RewriteEngine on RewriteRule ^/in(.*).html$ /index.php