A detailed approach to the pseudo-static configuration of PHP

Source: Internet
Author: User
I believe most programmers know that PHP pseudo-static is a static page that transforms a dynamic page into an HTML suffix, in fact, in the server resource loading process, is still a dynamic page, just to make the page more friendly. Specific pseudo-static meaning, we can again Baidu Encyclopedia search, here is not much to repeat.

Below we talk about the PHP pseudo-static configuration method under Apache:

1. Detects if Apache supports mod_rewrite to view the environment configuration via PHP's Phpinfo () function, ctrl+f find "Loaded Modules", which lists all modules that have been opened by Apache2handler , if it includes "mod_rewrite", it is already supported and no longer required to continue setting.
if "mod_rewrite" is not turned on, open the directory under your Apache installation directory "/apache/conf/" under the httpd.conf file, ctrl+f find to "LoadModule Rewrite_ Module "To remove the previous" # "number.
if not found, go to the "LoadModule" area and add "LoadModule rewrite_module modules/mod_rewrite.so" (a required exclusive row) on the last line. Then restart the Apache server.

2. create a. htaccess file
A. Method One: It is best to use VIM to build this file, should be for this file is no file name, operation is not very convenient.

B. Method two: new Htaccess.txt

Open With Notepad, click File – Save As, enter ". htaccess" in the File name window, then click Save. This file must be saved in the root directory of the Web site
3. Let Apache server support. htaccess
Modify the httpd.conf file

Options followsymlinks  allowoverride None


Options followsymlinks  allowoverride All

4. Fill in the site pseudo-static rules (need to understand regular expressions)

<ifmodule mod_rewrite.c>rewriteengine onrewriterule index.html$ index.php RewriteRule index-([1-9]+[0-9]*]. html$ index.php?p=$1//Rule The space between this side can not be missed write, do not write wrong, otherwise live report internal Server error error.  </IfModule>

When writing pseudo-static rules, you should keep valuable parameters and do not simplify all the valuable parameters. Index.php in the previous example? P=$1 rewrite to Index-p.html, (p represents the value passed in)

5. The input format looks like this:

When we enter the form of HTML, the same page as the normal PHP file type appears


I believe that through the reading of this article, we all know how to configure the PHP pseudo-static, I hope that your work has helped!

Related recommendations:

A written explanation of the pseudo-static rules of PHP

PHP implementation of pseudo-static URL text

PHP pseudo-static mode open

What is pseudo-static? PHP uses pseudo-static meaning?

php pseudo-Static text code detailed introduction

Related Article

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.