Php pseudo-static steps

Source: Internet
Author: User
Php implements the pseudo-static method mod_rewrite is a very powerful feature of Apache, which can implement pseudo-static pages. The following describes how to use it in detail. 1. check whether Apache supports mod_rewrite. check the Environment configuration through the phpinfo () function provided by php. use C php to implement pseudo-static methods.
The php pseudo-static method mod_rewrite is a very powerful feature of Apache, which can implement pseudo-static pages. The following describes how to use it in detail. 1. check whether Apache supports mod_rewrite. use the phpinfo () function provided by php to view the environment configuration. use Ctrl + F to find "Loaded Modules", which lists all Modules enabled by apache2handler, if "mod_rewrite" is included, it is supported and you do not need to set it again. 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 no result is found, add "LoadModule rewrite_module, modules/mod_rewrite.so" to the last row in the "LoadModule" area, and then restart the apache server. 2. how can I enable the apache server to support. htaccess to enable the local APACHE server to support ". htaccess? In fact, you only need to modify the httpd. conf settings of apache to enable APACHE to support. htaccess. Open the httpd. conf file (where? In the CONF Directory of the APACHE Directory), open it in a text editor and change Options FollowSymLinksAllowOverride None to Options FollowSymLinksAllowOverride All. 3. create. the htaccess file can be created in the simplest way. htaccess file: open it in Notepad, click File-save as, and enter "in the file name window ". htaccess ", note that the entire green part, that is, contains English quotation marks, and then click save. 4. to learn the rewrite rules, create a new one. after the htaccess file, write the following content in it: RewriteEngine on # rewriteengine is the rewrite engine switch on to turn off RewriteRule ([0-9] {1,}) $ index. php? Id = $1 RewriteRule: RewriteRule is a rewrite rule that supports regular expressions. the above ([0-9] {1,}) is composed of numbers, $ indicates the end sign. it indicates that the end is a number! Okay, now we can implement the pseudo-static page. write down the rule: RewriteEngine onRewriteRule (%a-za-z%}1,%}-(%0-9%}1,%}.html $ index. php? Action=100001&id=%2(%a-za-z%1,%}-(%0-9%}1,%}.html $ is the rule, index. php? Action = $1 & id = $2 is the format to be replaced. $1 indicates the matching value of the first parenthesis, $2 indicates the second, and so on !! Let's write a PHP script for processing: index. phpPHP code echo 'your Action is :'. $ _ GET ['action']; echo ''; echo 'your ID is :'. $ _ GET ['id'];?> Okay, now we enter: localhost/page-18.html output in the browser: your Action is: page your ID is: 18 original address: http://www.software8.co/wzjs/PHPshili/896.html

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.