I want the search result URL become

http://www.site.com/search/node/Search for something.html

I've looked into custom_url_rewrite_outbound() but there is not much I can understand

1 Answer 1


custom_url_rewrite_outbound() is not the only function you need to place in settings.php; you need also custom_url_rewrite_inbound(), which converts back the URL to the one known by Drupal.

For those functions, you can use code similar to the following one:

function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
  if (preg_match('|^search/([^/]+)/(.+)|', $path, $matches)) {
    $path = 'search/' . $matches[1] . '/' . $matches[2] . '.html';

function custom_url_rewrite_inbound(&$result, $path, $path_language) {
  if (preg_match('|^search/([^/]+)/(.+)\.html$|', $path, $matches)) {
    $result = 'search/' . $matches[1] . '/' . $matches[2];
  • Actually, instead of custom_url_rewrite_inbound I would rather use a mod_rewrite rule.
    – user49
    Jul 25, 2013 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.