Chèn hậu tố .html vào tất cả các Drupal path

Trường hợp site của bạn bạn không muốn khoe rằng mình đang sử dụng Drupal, chèn thêm hậu tố .html vào các path của Drupal sẽ giúp ích. Drupal có module path để tạo tên giả cho các path hiện có, tuy nhiên, path chào cũng cần thêm hậu tố .html thì... sử dụng module path hơi phí. Bạn chèn đoạn mã sau vào file settings.php, magic sẽ được thực hiện:

Drupal 5

<?php
/**
 * Written by The Hong  toila.net
 */
function custom_url_rewrite($op$result$path) {
  global 
$user;
  
  if (
$op === 'alias') {
    return 
$user->uid $result "{$result}.html";
  }
  elseif (
$op === 'source') {
    
$path $user->uid $path str_replace ('.html'''$path);
    
$r = <a href="http://toila.net/category/t%E1%BA%A1p-ghi/drupal.html">drupal</a>_lookup_path('source'str_replace ('.html'''$path));
    return 
$r $r $path;
  }
}
?>

Drupal 6

<?php
function custom_url_rewrite_inbound(&$result$path$path_language) {
  
$path str_replace ('.html'''$result);
  
$result drupal_lookup_path('source'$path$path_language);

  if (!
$result) {
    
$result $path;
  }
}

function 
custom_url_rewrite_outbound(&$path, &$options$original_path) {
  if (!empty (
$path)) {
    
$path .= '.html';
  }
}
?>

Thế Hồng

Comments

Hèn gì mấy hôm trước thấy

Hèn gì mấy hôm trước thấy toila có đuôi .html. ^^

toila.net không áp dụng tính

toila.net không áp dụng tính năng này đâu, nếu áp dụng thì ảnh hường lên tất cả các trang, thí dụ, /admin.htmlk, /admin/build.html, ... chỉ nên áp dụng cho các site mới, đổi link là tai hại lắm à nghen.

^_^

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <sup> <br> <p> <h3>
  • Lines and paragraphs break automatically.
  • Link to content with [[some text]], where "some text" is the title of existing content or the title of a new piece of content to create. You can also link text to a different title by using [[link to this title|show this text]]. Link to outside URLs with [[http://www.example.com|some text]], or even [[http://www.example.com]].
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.