First let Apache support .htaccess, skip this step if it is already enabled
(Use the phpinfo() function, search for "mod_rewrite", if found, it is enabled).
1. Configuration file httpd.conf
(1)
Options Indexes FollowSymLinks
AllowOverride None
change to
Options Indexes FollowSymLinks
AllowOverride All
(2)Remove the following ## note
LoadModule rewrite_module modules/mod_rewrite.so
2. The file .htaccess in the root directory of the configuration file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ([a-zA-Z0-9]{1,})-([a-zA-Z0-9]{1,}).html$ a/index.php?action=$1&id=$2
</IfModule>
windows environment
RewriteRule ^/abc$ /index.PHP (valid in httpd.conf, invalid in .htaccess)
RewriteRule ^abc$ /index.php (not valid in httpd.conf, valid in .htaccess)
例:RewriteRule ([a-zA-Z0-9]{1,})-([a-zA-Z0-9]{1,}).html$ a/index.php?action=$1&id=$2
www.XXX.com/article-233.html
Equivalent to www.XXX.com/a/index.php?action=article&id=233
例:RewriteRule a/([a-zA-Z0-9]{1,})$ a/index.php?id=$1
www.XXX.com/a/233
Equivalent to www.XXX.com/a/index.php?id=233