Home > Article > Backend Development > How to develop PHP pseudo-static
What is pseudo-static:
Websites are divided into dynamic websites and static websites. Our common ones ending with html are generally static pages, and pages ending with .php.asp Generally, they are dynamic websites. Dynamic websites are called dynamic websites only when they interact with the database. Dynamic websites are not easily indexed by search engines, so they are called pseudo-static.
Pseudo-static, as the name suggests, is a fake static website. That is to say, in order for dynamic websites to be easily indexed by search engines, they use the server's rewirte to achieve a pseudo-static process.
First explain the advantages and disadvantages of pseudo-static
Benefits: (Recommended study: PHP programming from entry to proficiency)
1. Convenient for search engines, SEO, crawlers, simplified URLs, beautified URLs
2. Consider the programming language used on the website It is not easy to be discovered. By rewriting the pseudo-static, the program suffix of the dynamic web page is changed into the static page format of html.
Disadvantages:
If the traffic is slightly larger and pseudo-static is used, the CPU usage will be overloaded. I have more than 300 people online at the same time and hang up without using pseudo-static. When it is static, more than 500 people are online at the same time without being disconnected. My ISS number is 1000. "This is indeed the case. Since pseudo-static uses regular expressions instead of real addresses, the responsibility for determining which page to display is also transferred to the CPU from direct designation. Let’s judge, so the increase in CPU usage is indeed the biggest disadvantage of pseudo-static.
How to use php to implement pseudo-static:
First, print your phpinfo (); Check whether Loaded Modules has mod_rewrite. If so, you can start the next step. If not, open the httpd.conf file under your apache installation directory "/apache/conf/" and search for "LoadModele rewrite_module" ", just delete the "#" in front of it. If you can't find it, add a line "LoadModule rewrite_module, modules/mod_rewrite.so", and then restart the apache server.
Let the apache server Support .htaccess
Open httpd.conf, then search for AllowOverride None, and then change AllowOverride None to AllowOverride All.
Create the .htaccess file on the website Create Notepad in the root directory, right-click and save as .htaccess, encoding utf-8.
rewrite rules
RewriteEngine on //重写引擎的开关,on开启,off关闭 RewriteRule //重写规则,这里我无法做过多的解释,其实我也不会写,反正我用的tp3.2,这是tp的重写规则
The above is the detailed content of How to develop PHP pseudo-static. For more information, please follow other related articles on the PHP Chinese website!