Home >Backend Development >PHP Tutorial >Simple implementation of Search Engine Friendly URL_PHP tutorial using PHP
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