Php,apache Pseudo-Static

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.