Get the App
SLTechnology News&Howtos  ›  Development  › 

PHP pseudo-static Rewrite setting APACHE procedure

Shulou Source: shulou.com Published: 2022-06-03 19:45:52 09月12日 Update

This article introduces the knowledge of "PHP pseudo-static Rewrite setting APACHE process". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Apache configuration:

1. Support httpd.conf configuration

2. Support directory .htaccess configuration (a "distributed configuration" file for virtual space, space merchants are not allowed to modify Apache configuration files)

Enable Rewrite (httpd.conf)

(sometimes something goes wrong with Options Indexes FollowSymLinks. You just need to configure Options all)

LoadModule rewrite_module modules/mod_rewrite.so

Enable .htaccess

AllowOverride None is modified to: AllowOverride All

2. Mod_rewrite rules:

For example:

RewriteEngine on-> start the rewrite engine RewriteRule ^ / test ([0-9] *). Html$ / test.php?id=$1-> refers to accessing test and any field .html can jump to test.php regular matching fields stored in virtual memory matching $1

III. Mod_rewrite rule modifiers

1) R forces external redirection

2) F disable URL and return 403HTTP status code.

3) G forces URL to be GONE and returns 410HTTP status code.

4) P forcibly use proxy forwarding.

5) L indicates that the current rule is the last rule, stop analyzing the rewriting of the rule after.

6) N re-start the rewrite process from the first rule.

7) C is associated with the next rule

If the rules match, it will be handled normally, and the following modifiers are invalid.

8) T=MIME-type (force MIME type) mandatory MIME type

9) NS is only used for non-internal sub-requests

10) NC is not case sensitive

11) QSA append request string

12) NE is not in output escape special character\% 3d$1 is equivalent to = $1

For example:

RewriteRule ^ / new ([0-9] *) / $/ new.php?id=$1 [R]

Simple small example:

RewriteEngine onRewriteRule ^ / in (. *). Html$ / index.php "PHP pseudo-static Rewrite setting APACHE process" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Rules configuration procedures enforcement static content fields characters files more status knowledge space support output practical special learned next memory Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Xiaomi Microsoft Redmi MySQL