URL Design of search engine friendly

Source: Internet
Author: User

URL Design of search engine friendly

Copyright statement: You can reprint it at will. Please mark it as a hyperlink during reprinting.ArticleSource and author information and this statement
Http://www.chedong.com/tech/google_url.html
Keywords: "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 Google'sAlgorithmThe investigation mentioned that the number of pages indexed by a website by Google 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:

Based on URL rewrite
Based on path_info
use the URI address as a parameter for passing: URL rewrite
the simplest is URL Conversion Based on the URL rewriting (rewrite) module in various web servers:
in this way, the implementation of the Program can be hardly modified. asp? 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 to add news. asp? When the 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
the corresponding rewrite module also exists in IIS: for example, ISAPI rewrite and IIS rewrite are based on regular expressions. Therefore, the configuration is almost the same as that in Apache mod_rewrite:
for a simple application, you can:
rewriterule/news/(\ D + )\. html/news \. PHP \? Id = $1 [N, I]
so that the http://www.chedong.com/news/234.html is mapped to the http://www.chedong.com/news/news.php? Id = 234

a more general expression that can map all dynamic pages to parameters is:
put the http://www.myhost.com/foo.php? A = A & B = B & C = C
: 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 advantage of URL rewrite is to hide the background implementation, which is useful for background application platform migration: when migrating from ASP to the Java platform, foreground users cannot feel the changes of 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.
URL beautification Based on path_info
another method of URL beautification is based on path_info:
path_info is a CGI 1.1 Standard, it is often found that many of the "/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"
, therefore, PHP Servlet and so on are all supported. For example, the servlet contains the request. getpathinfo () method.
Note:/MyApp/servlet/Hello/Foo's getpathinfo () 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:
<Filesmatch "^ app_name $">
Forcetype application/X-httpd-PHP
</Filesmatch>

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/

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.