Table of Contents
Regarding PHP pseudo-static Rewrite settings, the main function of php pseudo-rewrite
RewriteRule ^(.*)/classlist/(.*)$ $1/class_list.php?type=$2
Home Backend Development PHP Tutorial About PHP pseudo-static Rewrite settings, php pseudo-rewrite_PHP tutorial

About PHP pseudo-static Rewrite settings, php pseudo-rewrite_PHP tutorial

Jul 13, 2016 am 10:21 AM

Regarding PHP pseudo-static Rewrite settings, the main function of php pseudo-rewrite

Rewirte is to realize URL jump and hide the real address, based on the regular rules of Perl language Expression specification. We usually help us achieve pseudo-static, pseudo-directory, domain name jump, prevent hot links, etc. ​ 1. Apache configuration: ​ 1. Support httpd.conf configuration 2. Support directory .htaccess configuration (a "distributed configuration" file for virtual space, the space provider does not allow modification of the Apache configuration file) ​ Enable Rewrite (httpd.conf) (Sometimes there will be problems with Options Indexes FollowSymLinks, just configure Options all) LoadModule rewrite_module modules/mod_rewrite.so ​ Enable .htaccess AllowOverride None Modified to: AllowOverride All ​ 2. mod_rewrite Rules: For example: RewriteEngine on                                                                                                                                                                                                       - ​ RewriteRule ^/test([0-9]*).html$ /test.php?id=$1  -> Refers to accessing test and adding any field.html can jump to test.php. The regular matching fields are stored Match $1 in virtual memory ​ ​ 3. mod_rewriteRulesModifier ​ ​ 1) R forces external redirection 2) F disables URL and 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 runs the rewriting process starting from the first rule again. 7) C is associated with the next rule ​
If the rule matches, it will be processed normally, and the following modifiers are invalid
​ 8) T=MIME-type(force MIME type) force MIME type 9) NS is only used for non-internal subrequests 10) NC is not case sensitive 11) QSA append request string 12) NE no longer outputs escaped special characters %3d$1 is equivalent to =$1 ​ ​ For example: RewriteRule ^/new([0-9]*)/$ /new. php?id=$1 [R] ​ ​ Simple small example: Easy to achieve~

1

2

<span>RewriteEngine on

RewriteRule </span>^/in(.*).html$ /index.php

Copy after login
​ ​

Apache configuration Rewrite problem PHP|Pseudo-static|RewriteRule

RewriteEngine On

RewriteRule ^(.*)/classlist/(.*)$ $1/class_list.php?type=$2

The virtual host is a Linux system, and the running environment of the website program is php+mysql. How to set up pseudo-static? ?



Hello, you have to set up pseudo-static according to your website program and WEB server environment. For example, if you use LNMP environment and the PHP program you use is DZ2.5, then your pseudo-static can be:
rewrite ^( [^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2last;
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, please +Q+group 222802357 to find the group owner.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/852743.htmlTechArticle Regarding PHP pseudo-static Rewrite settings, the main function of php pseudo-rewrite Rewirte is to realize URL jump and hide the real address , based on the regular expression specification of the Perl language. Usually help us...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Customizing/Extending Frameworks: How to add custom functionality. Customizing/Extending Frameworks: How to add custom functionality. Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

What exactly is the non-blocking feature of ReactPHP? How to handle its blocking I/O operations? What exactly is the non-blocking feature of ReactPHP? How to handle its blocking I/O operations? Apr 01, 2025 pm 03:09 PM

An official introduction to the non-blocking feature of ReactPHP in-depth interpretation of ReactPHP's non-blocking feature has aroused many developers' questions: "ReactPHPisnon-blockingbydefault...

See all articles