Home > Backend Development > PHP Tutorial > Drupal code implements URL rewriting_PHP tutorial

Drupal code implements URL rewriting_PHP tutorial

WBOY
Release: 2016-07-21 15:30:25
Original
894 people have browsed it

The following is an implementation example:

Copy code The code is as follows:

/*
* Pseudo address to original address (url_alter )
*/
function example_url_inbound_alter(&$path, $original_path, $path_language)
{
if (preg_match('|^article(/.*)|', $path, $matches )) {
$path = 'node'. $matches[1];
}
}
/*
* Original address to pseudo address (url_alter)
*/
function example_url_outbound_alter(&$path, &$options, $original_path)
{
if (preg_match('|^node(/.*)|', $path, $matches)) {
$path = 'article' . $matches[1];
}
}

PS: When implementing hook_url_inbound_alter, the implementation function cannot be called out for some reason. It may be because HOOK is loaded prematurely. , the module is not fully loaded. So my approach is to write it in the URL rewriting module, such as subpath_alias

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323213.htmlTechArticleThe following is an implementation example: Copy the code as follows: /* * Pseudo address to original address (url_alter) */ function example_url_inbound_alter( } } /* * Convert original address to pseudo address (url_alter) */ funct...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template