Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

PHP pseudo-static Rewrite setting APACHE procedure

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report