drupal 代码实现URL重写_php技巧
May 17, 2016 am 09:19 AM
drupal
url rewrite
以下是实现例子:
复制代码 代码如下:
/*
* 伪地址转原地址 (url_alter)
*/
function example_url_inbound_alter(&$path, $original_path, $path_language)
{
if (preg_match('|^article(/.*)|', $path, $matches)) {
$path = 'node'. $matches[1];
}
}
/*
* 原地址转伪地址 (url_alter)
*/
function example_url_outbound_alter(&$path, &$options, $original_path)
{
if (preg_match('|^node(/.*)|', $path, $matches)) {
$path = 'article' . $matches[1];
}
}
PS: 实现hook_url_inbound_alter时不知为何会调不出实现函数,可能因为HOOK过早加载,没有把module加载完全。所以我的做法是写在URL重写模块中,例如subpath_alias
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

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to use Nginx for request redirection and URL rewriting

How does PHP handle URL rewriting and beautification?

How to use Nginx for redirection and URL rewriting of HTTP requests

Golang learning Web application development based on Drupal

How to improve the performance of your Drupal website through PHP-FPM optimization

Preventing URL Rewriting Attacks: Website Security Development Practices

Using routing components to implement URL rewriting and parameter parsing in PHP
