1. Check whether Apache supports mod_rewrite
View the environment configuration through the phpinfo() function provided by php, and find "Loaded Modules" through Ctrl+F, which lists all the modules that
apache2handler has opened, if it includes "mod_rewrite" , it is already supported and no further settings are required.
If "mod_rewrite" is not turned on, open the httpd.conf file
under your apache installation directory "/apache/conf/", use Ctrl+F to find "LoadModule rewrite_module", and replace the "#" sign in front Just delete it.
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 the virtual host in httpd.conf
# Virtual hosts Enable virtual host
Include conf/extra/httpd-vhosts.conf
3. Configure the corresponding options in the httpd_vhosts.conf file. Detailed explanation
< VirtualHost *:80>
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, then it cannot be listed.
options +Indexes
#The following means that the .htaccess file can be read, or it can be configured 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 is under linux, it can be created directly,
If it is under windows Under the platform, use Notepad to create a file, such as abc.txt, and then save it as a .htaccess file. 5. Rewrite the rules, or directly configure it in the