Enable PHP pseudo-static

Source: Internet
Author: User

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:

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.