English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Difference Between PHP Redirect and Fake Static

What is pseudo-static

Pseudo-static is relative to the real static
Pseudo-static just changes the URL to a static form, but it is still a dynamic web page in reality
The pseudo-static has the same SEO as the real static

What is redirection (very common, important to study)

Redirect the network request to a new direction, to another location
It is divided into internal and external, the difference is that when performing external redirection, the URL in the browser address bar will change
HTTP originally supports redirection3XX
Use redirection technology to implement pseudo-static

Redirection environment setup

Install web server (apache/nginx)
Load mod_rewrite.so module

Redirection implementation methods (mainly3)

Through configuration of WEB server main configuration <DIRECTORY> (production environment)
Through .htaccess (development environment)
Through script implementation (external redirection)

.htaccess redirection implementation steps

First step: Configure allowOverride All in the apache main configuration file (restart)
Second step: Configure in the .htaccess file

RewriteEngine on 
RewriteRule ^(.*)\.html$ $1.php  //Match HTML to PHP

WEB server main configuration to implement redirection

Directly find <DIRECTORY> in the Apache configuration file is the web project address, and add the following code below:

RewriteEngine on 
RewriteRule ^(.*)\.html$ $1.php  //Match HTML to PHP

RewriteRule syntax description

RewriteRule matching pattern replaced URL [flags]
Matching patterns support Prel regular expressions and rewrite variables
The replaced URL supports matching pattern results and rewrite variables
Multiple flags are separated by commas (for example: [R=301,C])

RewriteRule flags description

R强制外部重定向,浏览器地址栏url会发生变化,301Permanent redirection,302Temporary redirection, example: [R=301] [R] (represent301)
C Link the next rule, if there are multiple rules, then the current rule with [C] and the next rule become a whole, if the first day does not match, then the next one does not enter
L Stop matching the following rules, if there are multiple rules, when a rule with [L] matches, stop matching the following rules
NE does not escape special characters in URLs
NC case insensitive
G The web page requested fails, the server returns410
QSA for extracting query strings in URLs

You May Also Like