1. Locate the httpd.conf file under Conf in the Apache installation directory to open the file modification
LoadModule Rewrite_module modules/mod_rewrite.so This line of code, he has a # number in front of it, the # is erased
2. Still the file, open, find
<directory/>
Options followsymlinks execcgi Indexes
AllowOverride None
Order Deny,allow
Deny from all
Satisfy All
</Directory>
This node, change none to all. 3. Restart Apache Service
4. The most critical point is to create the. htaccess file in your project directory, the file has no name, it looks like the suffix name only
The specific creation method can not be created directly, create a TXT file (the other line), and then save the question, change the name to. htaccess, and select all the files, after the creation, it is necessary to make rules. Write the code in the file:
<ifmodule mod_rewrite.c> rewriteengine on//on for open, off for off
Rewriterule ([A-za-z]{1,})-([0-9]{1,}). html$ index.php?action=$1&id=$2 </IfModule>
([A-za-z]{1,})-([0-9]{1,}). html$ is the rule, the index.php?action=$1&id=$2 is the format to be replaced, the value that represents the first parenthesis match, and the second one, and so on!!
5. Create a PHP file (this file will, of course, be created in the project where you put the. htaccess file)
<?php
echo "Your action:". $_get[' action '); echo "Your ID:". $_get[' id ');
Then you access in the browser address bar: http://localhost/text/a-1.html, this address is equivalent to your visit to http://localhost/text/index.php?action=a&id=1. Do you think this is more beautiful?
The result of the visit is your action:a your id:1
PHP rewrite URL