Enable PHP pseudo-static
1. Check whether Apache supports mod_rewrite.
Use the phpinfo () function provided by php to view the environment configuration, and use Ctrl + F to find "Loaded Modules", which lists all Modules enabled by apache2handler. If "mod_rewrite" is included ", this parameter is supported and does not need to be set.
If "mod_rewrite" is not enabled, open httpd in the directory of your apache installation directory "/apache/conf. in the conf file, use Ctrl + F to find "LoadModule rewrite_module" and delete.
If not found, add "LoadModule rewrite_module modules/mod_rewrite.so" to the last row in the "LoadModule" area, and then restart the apache server.
2. Configure the virtual host in httpd. conf
# Enable Virtual host in Virtual hosts
Include conf/extra/httpd-vhosts.conf
3. Configure the corresponding options in the httpd_vhosts.conf file.
<VirtualHost *: 80>
DocumentRoot "C:/myenv/apache/htdocs/static3"
ServerName www.bkjia.com
<Directory "C:/myenv/apache/htdocs/static3">
# Deny from All 403 error prompt
Allow from All
# If the file directory is outside the apache directory and optinos is commented out, the list cannot be displayed.
Options + Indexes
# The following indicates that the. htaccess file can be read or configured directly on the VM.
Allowoverride All
RewriteEngine On
RewriteRule news-id (\ d00000000.html $ error. php? Id = $1
# Multiple rewrite rules can be set here
# RewriteRule news-id.html $ error. php
</Directory>
</VirtualHost>
4. Write the. htaccess rewrite rule in the corresponding directory
Example:
<IfModule rewrite_module>
RewriteEngine On
RewriteRule news-id (\ d1_0000.html $ show. php? Id = $1
# Multiple rewrite rules can be set here
# RewriteRule news-id.html $ error. php
</IfModule>
If you can directly create a file in linux,
In Windows, create a file with a notebook, such as abc.txt, and save
Is the. htaccess file.
5. Rewrite Rules. You can also directly configure the <Directory> segment of the virtual host.
This article permanently updates the link address: