Home  >  Article  >  Backend Development  >  Simple implementation of Search Engine Friendly URL_PHP tutorial using PHP

Simple implementation of Search Engine Friendly URL_PHP tutorial using PHP

WBOY
WBOYOriginal
2016-07-13 17:32:35756browse

Last time I wrote about the URL design of Search Engine Friendly - I was struggling with this matter and wanted to implement this http://www.myhost.com/foo.php(as the current mainstream development language)?a=A&b=B&c=C -> http://www.myhost.com/foo.php(as the current mainstream development language)/a/A/b/B/ There are actually different ways to convert c/C URLs.

For example, if I use a virtual host and want to optimize URLs, but I don’t have server permissions, I can start with PATH_INFO.

Visit the url http://www.myhost.com/foo.php(as the current mainstream development language)/a/A/b/B/c/C At this time, if the AllowPathinfo of apache (the most popular WEB server platform on the Unix platform) has been opened, you can use php (as the current mainstream development language) to access $_SERVER[PATH_INFO] to obtain The string of characters a/A/b/B/c/C is then analyzed using php(as the current mainstream development language):

PLAIN TEXTphp(do For current mainstream development languages):

if(!empty($_SERVER[PATH_INFO])) {
$paths = explode(/, substr($_SERVER[PATH_INFO], 1) );
for($i = 0, $cnt = count($paths); $i <$cnt; $i++)
$_GET[$paths[$i]] = @(string)$ paths[++$i];
}

This way, you can simply convert PATH_INFO into the global $_GET array, which also has the advantage of

http://www. myhost.com/foo.php(as the current mainstream development language)?a=A&b=B&c=C
http://www.myhost.com/foo.php( As the current mainstream development language) /a/A/b/B/c/C
The above url can be accessed at the same time, ensuring versatility

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508680.htmlTechArticleLast time I wrote about the URL design of Search Engine Friendly - I was struggling with this matter to achieve this http:/ /www.myhost.com/foo.php (as the current mainstream development language) ?a=Ab=Bc=C - http://w...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn