1. Detect if Apache supports Mod_rewrite
The Phpinfo () function provided by PHP looks at the environment configuration and finds "Loaded Modules" through ctrl+f, which lists all
Apache2handler already open module, if include "mod_rewrite", then already support, no longer need to continue to set.
If "Mod_rewrite" is not turned on, open the directory under your Apache installation directory "/apache/conf/" httpd.conf
To "LoadModule Rewrite_module" by ctrl+f, remove the "#" number from the front.
If not found, go to the "LoadModule" area, add "LoadModule rewrite_module modules/mod_rewrite.so" (Required exclusive line) to the last line, and then restart the Apache server.
2. Configuring the virtual Host in httpd.conf
# Virtual hosts enable hosting
Include conf/extra/httpd-vhosts.conf
3.httpd_vhosts.conf file, configure the appropriate options. Detailed explanation
<virtualhost *:80>
DocumentRoot "C:/MYENV/APACHE/HTDOCS/STATIC3"
ServerName www.hsp.com
<directory "C:/MYENV/APACHE/HTDOCS/STATIC3" >
#Deny from the all 403 error prompt
Allow from all
#如果文件目录在apache目录外面, comment out Optinos, not list.
Options +indexes
#下面这个表示可以去读取. htaccess files can also be configured directly in the virtual host.
AllowOverride All
Rewriteengine on
Rewriterule News-id (\d+). html$ error.php?id=$1
#这里可以设置多个重写的规则
#RewriteRule news-id.html$ error.php
</Directory>
</VirtualHost>
4. Write in the appropriate directory. Htaccess rewrite rules
Example:
<ifmodule rewrite_module>
Rewriteengine on
Rewriterule News-id (\d+). html$ show.php?id=$1
#这里可以设置多个重写的规则
#RewriteRule news-id.html$ error.php
</IfModule>
If you can create it directly under Linux,
If you are under the Windows platform, create a file with Notepad, such as Abc.txt, and then save
For the. htaccess file
5. Rewrite the rules, or you can configure the <Directory> segment of the virtual host directly.
Php,apache Pseudo-Static