mod_rewrite is a very powerful function of Apache, which can realize pseudo-static pages. 1. Check whether Apache supports mod_rewrite Check the environment configuration through the phpinfo() function provided by php, and use Ctrl+F to find "Loaded Modules", which lists all modules that have been enabled by apache2handler. If "mod_rewrite" is included, it is supported and no further settings are required. If "mod_rewrite" is not turned on, open the httpd.conf file under your apache installation directory "/apache/conf/", find "LoadModule rewrite_module" through Ctrl+F, and delete the "#" sign in front of it. Can. If it is not found, go to the "LoadModule" area, add "LoadModule rewrite_module modules/mod_rewrite.so" in the last line (required to be an exclusive line), and then restart the apache server. 2, let apache server support .htaccess How to make the local APACHE server support ".htaccess"? Modify apache's httpd.conf settings to enable APACHE to support .htaccess. Open the httpd.conf file (where? In the CONF directory of the APACHE directory), open it with a text editor, and look for:
and you’re done. 3. Create .htaccess file If you are on the Windows platform, I really don’t know how to create the ".htaccess" file at first, because this file actually has no file name, just an extension. This file cannot be created through ordinary methods. Don’t worry, it will be done right away. Let me tell you three methods: The three methods all first create a text file of htaccess.txt (of course, you can name this text file whatever you want), and then there are three ways to rename this file: 1) Open it with Notepad, click File – Save As, enter ".htaccess" in the file name window, pay attention to the entire green part, which includes English quotes, and then click Save. 2) Enter the cmd command window, use cd to switch the folder where the htaccess.txt file was just created, then enter the command: rename htaccess.txt .htaccess, and then click the Enter key on the keyboard. 3) Connect the folder where htaccess.txt is located through ftp and rename it through ftp software. 4, rewrite rules Create a new .htaccess file and create the content:
RewriteRule: RewriteRule is a rewriting rule that supports regular expressions. The above ([0-9]{1,}) refers to being composed of numbers. $ is the end mark, indicating that it ends with a number! Implement pseudo-static page, rules:
to implement http://127.0.0.1/index.html and http://127.0.0.1/new-1.html |