SearchEngineFriendly URL design _ PHP Tutorial

Source: Internet
Author: User
The URL design of SearchEngineFriendly. SearchEngineFriendly's URL design copyright statement: This statement can be reproduced at will. during reprinting, please be sure to mark the original source and author information of the article in the form of a hyperlink and the URL design copyright statement of this statement www.chedong.com Search Engine Friendly: this statement can be reproduced at will. during reprinting, you must mark the original source and author information of the article in the form of a hyperlink and
Http://www.chedong.com/tech/google_url.htmlkey words: "url rewrite" mod_rewrite isapirewrite path_info "search engine friendly"
Summary:
In addition, as the content on the Internet grows at an astonishing rate, the importance of search engines is becoming increasingly prominent. if a website wants to be better indexed by search engines, the website design is not only user-friendly, the design of Search Engine Friendly is also very important. The more content you enter the search engine page, the more likely you will find using different keywords. In the Google algorithm survey article, we mentioned that the number of pages indexed by Google by a site has a certain impact on PageRank. Because Google highlights the relatively static parts of the entire network (the number of dynamic web page indexes is relatively small ), static web pages with relatively fixed link addresses are more suitable for Google indexing (no wonder many large websites can search for mailing list archives and archived documents on a monthly basis ), therefore, many articles on URL design optimization for search engines (URI Pretty) mentioned that dynamic web page parameters are converted into static web pages using certain mechanisms:
For example, you can set:
Http://www.chedong.com/phpMan.php? Mode = man & parameter = ls
To:
Http://www.chedong.com/phpMan.php/man/ls
There are two main implementation methods:
Use the URI address as a parameter based on url rewrite based on path_info: URL REWRITE
The simplest thing is to convert the URL based on the URL rewriting (Rewrite) module in various WEB servers:
In this way, the program implementation will be almost unchanged? The link id = 234 is mapped to news/234.html, and looks like a static link from the outside. The Apache server has a module (non-default): mod_rewrite: powerful enough to write a book.
When I need? When id = 234 is mapped to news/234.html, you only need to set:
RewriteRule/news/(\ d +) \. html/news \. asp \? Id = $1 [N, I]
In this way, requests such as/news/234.html are mapped to/news. asp? Id = 234
When there is a request for/news/234.html: the web server will forward the actual request to/news. asp? Id = 234
In IIS, there are also corresponding REWRITE modules, such as isapi rewrite and iis rewrite. The syntax is based on regular expressions, so the configuration is almost the same as that of apache mod_rewrite: for a simple application:
RewriteRule/news/(\ d +) \. html/news \. php \? Id = $1 [N, I]
So we map the http://www.chedong.com/news/234.html to the http://www.chedong.com/news/news.php? Id = 234

A more general expression that can map parameters of all dynamic pages is:
Put http://www.myhost.com/foo.php? A = A & B = B & c = C
The result is http://www.myhost.com/foo.php/a/a/ B/B /c/c/c.
RewriteRule (.*? \. Php )(\? [^/] *)? /([^/] *)/([^/] *) (. + ?)? $1 (? 2 $2 &:\?) $3 = $4? 5 $5: [N, I]
Another benefit of using url rewrite is to hide the background implementation, which is very useful for background application platform migration: when migrating from asp to java platform, for foreground users, however, we cannot feel the changes in background applications. For example, we need to extract the application from news. asp? Id = 234 migrate to news. php? When query is set to 234, the foreground performance can always be news/234.html. Separating the application from the foreground: This ensures the stability of the URL, while using mod_rewrite can even forward requests to other backend servers.
Another method of URL beautification based on PATH_INFO is based on PATH_INFO:
PATH_INFO is a CGI 1.1 standard. it is often found that many "/value_1/value_2" following CGI is The PATH_INFO parameter:
For example, http://www.chedong.com/phpman.php/man/ls,:$path_info = "/man/ls"
PATH_INFO is a CGI standard, so PHP Servlet and so on are all supported. For example, the Servlet contains the request. getPathInfo () method.
Note: getPathInfo () of/myapp/servlet/Hello/foo Returns/foo, while/myapp/dir/hello. getPathInfo () of jsp/foo will return/hello. jsp. from here, you can also know that jsp is actually a Servlet PATH_INFO parameter. ASP does not support PATH_INFO,

The example of PATH_INFO-based parameter parsing in PHP is as follows:
// Note: The parameters are separated by "/". The first parameter is null: The $ param1 $ param2 parameter is parsed from/param1/param2.
If (isset ($ _ SERVER ["PATH_INFO"]) {
List ($ nothing, $ param1, $ param2) = explode ('/', $ _ SERVER ["PATH_INFO"]);
}

How to hide an application: for example,. php, the extension:
Configure in APACHE as follows:

ForceType application/x-httpd-php


How to make a static page more like: app_name/my/app.html
When the path_infoworkflow is complete, you can cut off the last 5“.html in the last step.
Note: in APACHE2, PATH_INFO is not allowed by default. you need to set AcceptPathInfo on

PATH_INFO is usually the only option when you are not authorized to install and configure mod_rewrite for VM users.

OK. Now, you can see a webpage similar to http://www.example.com/article/234. can it be article/show. php? Id = 234 the dynamic web page generated by this php program. many websites may have many static directories on the surface. In fact, it is very likely that the content is published using 1 or 2 programs. For example, many WIKIWIKI systems use this mechanism: the entire system is a simple wiki program, and the directory that appears is actually the query result of the application using the following address as the parameter.

Using the MOD_REWRITE/PATH_INFO + CACHE server solution to transform the original dynamic release system can also greatly reduce the cost of upgrading the old system to the new content management system. It also facilitates indexing by search engines. Appendix: how to install memo in ISAPI mode with PHP support for PATH_INFOPHP on IIS

Unpack Directory
==========
Php-4.2.3-Win32.zip c: \ php

PHP. INI initialization file
========================
Copy: c: \ php. ini-dist to c: \ winnt \ php. ini

Configuration file Association
================
Follow the instructions in install.txt to associate the configuration file

Running library file
============
Copy c: \ php \ php4ts. dll to c: \ winnt \ system32 \ php4ts. dll

After this operation: php maps PATH_INFO to the physical path.
Warning: Unknown (C: \ CheDong \ Downloads \ ariadne \ www \ test. php \ path): failed to create stream: No such file or directory in Unknown on line 0

Warning: Unknown (): Failed opening 'C: \ CheDong \ Downloads \ ariadne \ www \ test. php \ path 'for declaration (include_path = '.; c: \ php4 \ pear ') in Unknown on line 0

Install the PATCH of ariadne
============================
Stop IIS service
Net stop iisadmin
Ftp://ftp.muze.nl/pub/ariadne/win/iis/php-4.2.3/php4isapi.dll
Overwrite the original c: \ php \ sapi \ php4isapi. dll

Note:
Ariadne is a content publishing system based on PATH_INFO,
In PHP 4.3.2, the CGI PATH_INFO in RC2 has been fixed. install it as usual.
References:
URL Rewrite document:
Http://www.isapirewrite.com/docs/
Http://httpd.apache.org/docs/mod/mod_rewrite.html
Http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html
Search engine-friendly URL design
Http://www.sitepoint.com/article/485
Maybe this URL is articel. php? Id = 485
An open-source content management system based on PATH_INFO
Http://typo3.com/
What does Google have no index?
Http://www.microdocs-news.info/newsGoogle/2003/05/10.html
Google PageRank description:
Http://pr.efactory.de/

Http://www.bkjia.com/PHPjc/314578.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/314578.htmlTechArticleSearch Engine Friendly URL design copyright statement: Can be any reprint, reprint please be sure to mark the original source and author information in the form of hyperlink and this statement http://www.chedong.com...

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.