- Options FollowSymLinks
- AllowOverride None
Copy Code
Switch
- Options FollowSymLinks
- AllowOverride All
Copy Code
2, the establishment of. htaccess file three methods are first to create a htaccess.txt text file (of course, the name of the text file you can randomly take), and then there are three ways to rename the file: (1) Open with Notepad, click File – Save As, enter in the File name window. Htaccess ", note that the entire green section, that is, contains the English quotation marks, and then click Save on the line. (2) Go to cmd Command window, switch to the folder of the Htaccess.txt file by CD, then enter the command: Rename Htaccess.txt. htaccess, then click the keyboard enter key. (3) through the FTP connection Htaccess.txt folder, through the FTP software rename. (4) Third-party editors, such as Dreamweaver, can also create. htaccess.
3. Rewrite rules learn to create a new. htaccess file:
- Rewriteengine on #rewriteengine为重写引擎开关on为开启off为关闭
- Rewriterule ([0-9]{1,}) $ index.php?id=$1
Copy Code
Rewriterule is a rewrite rule that supports regular expressions, the above ([0-9]{1,}) refers to numbers, $ is the end flag, and the description is the end of the number! Pseudo-Static page rules:
- Rewriteengine on
- Rewriterule ([A-za-z]{1,})-([0-9]{1,}). html$ index.php?action=$1&id=$2
Copy Code
([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!!
index.php for testing
- Echo ' Your action is: '. $_get[' action '];
- Echo '
- ’;
- Echo ' Your ID is: '. $_get[' id '];
- ?>
Copy Code
In the browser input: http://jbxue.com/view-12.html output is: Your action is: View your ID is: 12
This is it, I hope to help you.
|