Home > Backend Development > PHP Tutorial > Turn on PHP pseudo-static

Turn on PHP pseudo-static

WBOY
Release: 2016-07-29 09:08:33
Original
966 people have browsed it

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 section of the virtual host.

The above introduces the pseudo-static function of enabling PHP, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template