PHP pseudo static Rewrite settings, php pseudo rewrite

Source: Internet
Author: User

PHP pseudo static Rewrite settings, php pseudo rewrite
The main function of Rewirte is to redirect URLs and hide real addresses. It is based on Perl-based regular expressions. It usually helps us achieve quasi-static, quasi-directory, domain name jump, and prevent leeching.I. ApacheConfiguration:1. Support for httpd. conf configuration 2. Support for directory. htaccess configuration (a "distributed configuration" file is intended for virtual spaces, and the Space provider does not want to modify the Apache configuration file)Enable Rewrite (httpd. conf)(Sometimes Options Indexes FollowSymLinks may fail. You only need to configure Options all.) LoadModule rewrite_module modules/mod_rewrite.soEnable. htaccessAllowOverride None: AllowOverride AllIi. mod_rewriteRules:Example: RewriteEngine on->StartRewriteEngineRewriteRule ^/test ([0-9] * example .html $/test. php? Id = $1-> When testtestplus any field. html can jump to the test. php RegEx matching field and store it in virtual memory matching $1
3. mod_rewriteRulesModifier1) R forces external redirection 2) F disables the URL and returns a 403HTTP status code. 3) If G forces the URL to be GONE, the response HTTP status code is returned. 4) P enforces proxy forwarding. 5) L indicates that the current rule is the last rule, and the rule is overwritten after analysis is stopped. 6) N re-run the rewrite process from the first rule. 7) C. associate with the next ruleIf the rule matches, it is processed normally. The following modifier is invalid.8) T = MIME-type (force MIME type) force MIME type 9) NS is only used for internal requests rather than 10) NC case-insensitive 11) QSA append request string 12) NE does not output escape special characters \ % 3d $1 is equivalent to = $1 for example:RewriteRule ^/New([0-9] *)/$/New. Php? Id = $1[R]Simple Example:

RewriteEngine onRewriteRule ^/in(.*).html$ /index.php

Easy to implement ~


PHP | pseudo-static | RewriteRule

<IfModule rewrite_module>
RewriteEngine On
RewriteRule ^ (. *)/classlist/(. *) $1/class_list.php? Type = $2
</IfModule>

The virtual host is a Linux system, and the website program runs in php + mysql. How can I set pseudo-static state ??

Hello, you have to set up pseudo-static based on your website program and WEB server environment. For example, if you use the LNMP environment, the PHP program is DZ2.5, so your pseudo-static can be:
Rewrite ^ ([^ \.] *)/topic-(. +) \. html $1/portal. php? Mod = topic & topic = $2 last;
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;
}

If you have any questions, contact the group owner in group Q + group 222802357.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.