Open PHP pseudo static mode, PHP pseudo static _php tutorial

Source: Internet
Author: User

Open PHP Pseudo-static mode, PHP pseudo-static


have been doing PHP development work. In the process of development has long been heard "pseudo-static" this said. But it has never been understood. Learn carefully today through this article.

First, what is pseudo-static:

Pseudo-static aka URL rewrite, is a dynamic URL that looks like a static URL. In other words, dynamic Web pages are implemented to remove the parameters of a dynamic Web page by overriding the URL method, but there is no need to implement a rewritten page in the actual Web page directory.

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

 
  
   
    DocumentRoot "C:/MYENV/APACHE/HTDOCS/STATIC3"  ServerName www.hsp.com #Deny from all  
  
   
    
   403 error prompt allow From all# If the file directory is outside the Apache directory, comment out Optinos, you cannot list. Options +indexes# The following means that you can read the. htaccess file, or you can configure it directly in the virtual host. allowoverride allrewriteengine onrewriterule News-id (\d+). html$ error.php?id=$1# Here you can set multiple overriding rules #rewriterule news-id.html$ error.php  
  
    
 
  

4. Write in the appropriate directory. Htaccess rewrite rules

Example:

 
  
   
  Rewriteengine onrewriterule News-id (\d+). html$ show.php?id=$1# Here you can set multiple overriding rules #rewriterule news-id.html$ error.php
 
  

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 as a. htaccess file.

5. Rewrite the rules, or you can configure the segment configuration of the virtual host directly .

Advantages and disadvantages of dynamic, static and pseudo-static (new)

Dynamic URLs

First of all, the dynamic URL for Google, "can not be crawled" is wrong, Google can handle dynamic URLs and smooth crawl, followed by "parameters can not exceed 3" is not correct, Google can crawl parameters more than 3 dynamic URLs, however, To avoid URLs that are too long, you should minimize the parameters.

Secondly, the dynamic URL has its certain advantages, to the above mentioned news.php? lang=cn&class=1&id=2, for example, the URL of the parameters accurately tell Google, this URL content language is CN, is classified as Category 1, Content ID 2, more convenient for Google to identify the content processing.

Finally, the dynamic URLs should be as concise as possible, especially the session ID (SID) and query parameters, which can easily cause a large number of identical pages.

Static URLs

First of all, the absolute advantage of static URLs is its clarity,/product/nokia/n95.html and/about.html can be easily understood, resulting in a relatively high number of hits in search results.

Second, the static URL is not necessarily the best form of the Web site, the dynamic URL said that dynamic URLs can tell Google some of the parameters can be identified, and static URLs if the document is not properly arranged (such as: too flat, the HTML document is placed in the root directory) and other factors, Rather than static URLs for Google to provide a rich reference information.

Finally, does it feel like Google has a hidden meaning in this article? "Updating pages of this type of URLs can be time-consuming, especially if the amount of information is growing fast because each individual page has to change the compiled code." "It's a website, but is there such a problem in Google's system?" he said.

Pseudo static URLs

First, pseudo-static URLs can not make dynamic URLs "static", pseudo-static is only a rewrite of dynamic URLs, Google does not think pseudo-static is an HTML document.

Second, pseudo-static preferable, but should focus on the removal of redundant parameters, canonical URLs, as far as possible to avoid repeating the page.

Finally, pseudo-static has great potential danger, preferably in the site system, website structure, content distribution, parameter meaning familiar with the case of the use.

When writing pseudo-static rules, you should retain valuable parameters and not all the valuable parameters, such as the news.php in the previous example? Lang=cn&class=1&id=2 is best rewritten as news-cn-class1-id2.html, rather than as an excessive refinement rewrite for news-2.html.

And then the pseudo-static must not contain the session ID (SID) and query parameters,/product.asp? sid=98971298178906&id=1234 such a dynamic URL, where the SID would have been recognized and blocked by Google, but if rewritten as/product/98971298178906/1234,google not only unrecognized, It also creates an infinite number of duplicate pages in the entire station (each session will produce a new session ID).

Articles you may be interested in:

    • PHP pseudo-Static code attached
    • PHP pseudo-Static page functions attached to the use of the method
    • Implement pseudo-static page code directly with PHP without mod_rewrite
    • Four methods of passing parameter names in PHP pseudo-static hiding
    • A detailed introduction to the implementation of PHP pseudo-static
    • Introduction of PHP pseudo-static technology principle and Breakthrough principle realization
    • thinkphp routing rules use examples to understand and pseudo-static functionality implementations (Apache overrides)
    • Apache Open pseudo-static method sharing
    • PHP pseudo-Static Apache chapter
    • PHP pseudo-Static IIS Chapter
    • PHP pseudo static rewrite settings Apache Chapter
    • Teaches you how to turn on SHOPNC b2b2c pseudo static
    • Configuring pseudo-Static for PHP in Linux

http://www.bkjia.com/PHPjc/1087283.html www.bkjia.com true http://www.bkjia.com/PHPjc/1087283.html techarticle open PHP Pseudo-static mode, PHP pseudo-static has been doing PHP development work. In the process of development has long been heard "pseudo-static" this said. But it has never been understood. This ...

  • 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.