1. Check whether Apache supports mod_rewrite
View the environment configuration through the phpinfo() function provided by php, and use Ctrl F Find "Loaded Modules", which lists all modules that
apache2handler has enabled. If "mod_rewrite" is included, it is already supported and no further settings are required.
If "mod_rewrite" is not enabled, open the httpd.conf file
under your apache installation directory "/apache/conf/" and use Ctrl F to find "LoadModule rewrite_module" ”, just delete the “#” sign in front.
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. Configure virtual host in httpd.conf
# Virtual hosts Enable virtual host
Include conf/extra/httpd-vhosts.conf
3. In the httpd_vhosts.conf file, configure the corresponding options. Detailed explanation
DocumentRoot "C:/myenv/apache/htdocs/static3"
ServerName www. hsp.com
#Deny from All 403 error message
Allow from All
#If the file directory is outside the apache directory , comment out optinos, it cannot be listed.
options Indexes
#The following means that you can read the .htaccess file, or you can configure it directly in the virtual host.
Allowoverride All
RewriteEngine On
RewriteRule news-id(d).html$ error.php?id=$1
#You can set multiple rewrite rules here
#RewriteRule news-id.html$ error.php
< /Directory>
4. Write .htaccess rewrite rules in the corresponding directory
Example:
RewriteEngine On
RewriteRule news-id(d).html$ show.php?id=$1
#You can set multiple rewrite rules here
#RewriteRule news-id.html$ error .php
If it can be created directly under Linux,
If it is under Windows platform, use Notepad to create a file, such as abc.txt, and then save it
Just .htaccess file
5. Rewrite rules can also be configured directly in the