Home > Article > Backend Development > Introduction to PHP pseudo-static URL REWRITE rewriting rules
Change to
2. Create .htaccess file The three methods all first create a text file htaccess.txt (of course, you can choose the name of this text file casually), and then there are three ways to rename this file: (1) Open 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 to 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) .htaccess can also be created through third-party editors such as Dreamweaver. 3. Learning rewrite rules Create a new .htaccess file:
RewriteRule is a rewriting rule that supports regular expressions. The above ([0-9]{1,}) refers to the number, and $ is the end mark, indicating that it ends with a number! Pseudo-static page rules:
([a-zA-Z]{1,})-([0-9]{1,}).html$ is the rule, index.php?action=$1&id=$2 is the requirement In the replacement format, $1 represents the value matched by the first bracket, $2 represents the second one, and so on! ! index.php for testing
and enter it in the browser: http://jbxue.com/view-12.html The output is: Your Action is: view Your ID is: 12 That’s it, I hope it helps everyone. |