Enable PHP pseudo-static mode, php pseudo-static _ PHP Tutorial

Source: Internet
Author: User
Enable the pseudo-static mode of PHP and the pseudo-static mode of php. When the pseudo-static mode of PHP is enabled, php pseudo-STATic has been developing php. during the development process, I have heard of the "pseudo-static" statement. But I have never understood it. PHP pseudo-static mode is enabled today, and php pseudo-static mode is enabled

I have been working on php Development. during the development process, I have long heard of the "pseudo-static" remark. But I have never understood it. I will read this article carefully today.

First, what is pseudo-static:

Pseudo-static URL rewriting is a dynamic URL that looks like a static one. In other words, dynamic web pages remove the parameters of dynamic web pages by rewriting the URL method, but there is no need to rewrite the pages in the actual web page Directory.

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
Apache2handler has enabled the module. if it contains "mod_rewrite", it is supported and does not need to be set any more.

If "mod_rewrite" is not enabled, open the httpd. conf file in the directory "/apache/conf /".
To find the "LoadModule rewrite_module" through Ctrl + F, and delete the "#" in front of the module.

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.

 
  
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 and optinos is commented out, it cannot be listed. options + Indexes # The following indicates that the data can be read. the htaccess file can also be directly configured in the VM. allowoverride AllRewriteEngine OnRewriteRule news-id (\ d000000000000.html $ error. php? Id = $1 # Here you can set multiple rewrite rules # RewriteRule news-id.html $ error. php
   
 

4. write the. htaccess rewrite rule in the corresponding directory

Example:

 
  
RewriteEngine OnRewriteRule news-id (\ d?#.html $ show. php? Id = $1 # Here you can set multiple rewrite rules # RewriteRule news-id.html $ error. php
 

If you can directly create a file in linux,

In Windows, create a file with a notebook, such as abc.txt, and save it as a. htaccess file.

5. rewrite the rules. you can also directly configure Segment configuration.

Benefits and disadvantages between dynamic, static, and pseudo-static (new)

Dynamic website

First, it is wrong for Google to say "cannot be crawled". Google can handle dynamic websites well and capture them smoothly; the statement "no more than three parameters" is also incorrect. Google can capture dynamic URLs with more than three parameters. however, to avoid too long URLs, we should minimize the number of parameters.

Secondly, dynamic web sites have some advantages. what is news. php mentioned above? Lang = cn & class = 1 & id = 2 as an example. the URL parameters tell Google exactly that the URL content language is cn, belongs to Category 1, Content ID is 2, it is easier for Google to recognize and process content.

Finally, the dynamic Web site should be simplified as much as possible, especially the session id (sid) and query parameters, which may cause a large number of identical pages.

Static Website

First, the absolute advantage of the static website is its clarity./product/nokia/n95.html and/about.html can be easily understood, so that the number of clicks in the search results may be relatively high.

Second, static websites may not be the best form of websites. as mentioned in the above dynamic websites, dynamic websites can tell Google some identifiable parameters, and static websites are not properly configured if the documents (for example: it is too flat to put all HTML documents under the root directory) and other factors, but it is not as informative as the reference provided by the static website for Google.

Finally, I think Google has hidden meanings in this article? "Updating pages of this type of website is time-consuming, especially when the amount of information increases rapidly, because every single page must change the compilation code ." Although I am talking about websites, is there such a problem in Google?

Pseudo static website

First, the pseudo-static website cannot make the dynamic website "static". the pseudo-static website is only a rewriting of the dynamic website. Google does not regard the pseudo-static website as an HTML document.

Second, pseudo-static is desirable, but the focus should be on removing redundant parameters, standardizing URLs, and avoiding duplicate pages as much as possible.

Finally, pseudo-static data poses great potential risks. it is best to use it when you are familiar with the website system, website structure, content distribution, and parameter meanings.

When writing pseudo-static rules, you should keep valuable parameters. do not streamline all valuable parameters, such as news. php in the previous example? Lang = cn & class = 1 & id = 2 it is best to rewrite to news-cn-class1-id2.html instead of oversimplified to news-2.html.

Then, the pseudo-static file must not contain the session id (sid) and query parameters,/product. asp? Sid = 98971298178906 & id = 1234, where the sid can be recognized and blocked by Google, but if it is rewritten as/product/98971298178906/1234, Google will not be able to recognize it, there are still infinite duplicate pages on the entire site (each session generates a new session ID ).

Articles you may be interested in:
  • PHP pseudo-static writing with code
  • PHP pseudo-static page function Appendix usage
  • Use php directly to implement pseudo-static page code without mod_rewrite
  • PHP pseudo-static hiding four methods for passing parameter names
  • Php-based pseudo-static implementation
  • Introduction to PHP pseudo-static technology principles and breakthrough principles
  • Detailed examples of thinkphp routing rules and implementation of pseudo-static functions (apache rewrite)
  • How to enable pseudo-static in apache
  • APACHE for php pseudo-static
  • Php pseudo-static IIS
  • APACHE for PHP pseudo-static Rewrite settings
  • How to enable shopnc b2b2c pseudo-static
  • Configure pseudo-static for php in Linux

Ghost has been working on php Development. during the development process, I have long heard of the "pseudo static" statement. But I have never understood it. Today...

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.