应该只对url函数输出有效。
例子(写在settings.php里):
function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
global $user;
// Change all 'node' to 'article'.
if (preg_match('|^node(/.*)|', $path, $matches)) {
$path = 'article' . $matches[1];
}
// Create a path called 'e' which lands the user on her profile edit page.
if ($path == 'user/' . $user->uid . '/edit') {
$path = 'e';
}
if (preg_match('|/imagecache/|', $path, $matches)) {
$options['base_url'] = 'http://www.mirror.com';
$options['absolute'] = true;
}
}
function custom_url_rewrite_inbound(&$result, $path, $path_language) {
global $user;
// Change all article/x requests to node/x
if (preg_match('|^article(/.*)|', $path, $matches)) {
$result = 'node' . $matches[1];
}
// Redirect a path called 'e' to the user's profile edit page.
if ($path == 'e') {
$result = 'user/' . $user->uid . '/edit';
}
}
评论