Drupal, disable the path

I have a drupal site using taxonomy. Now google indexed taxonomy paths like: http://mysite.com/term/5865 .

Now most taxonomy pages should not be accessible, and I want to delete this path, but I can not find how to do it anywhere.

Does anyone have an idea how to do this?

Thanks in advance.

+3
source share
4 answers

Create a module called kill_taxonomy, and then add the following code to the kill_taxonomy.module file

<?php 
/**
 * Implementation of hook_menu_alter.
 */
function kill_taxonomy_menu_alter(&$items) {
 unset($items['taxonomy/term/%']);
}
?>

Enable the module.

+3
source

, hook_menu_alter. , , - taxonomy/term/%term.

- . , .

.

- / .

+1

, , . / Drupal google . , ?

// robots.txt, Bryan $items ['taxonomy/term/%'], .

, GOTCHA, - Advanced Forums, RSS- . .

, Vocab , , RSS- $items ['//%'] .

:

URL Alter Module custom_url_rewrite_inbound(), :

//If path is taxonomy/term/% we force 404
if (preg_match("/^taxonomy\/term\/([0-9]+)(\/.*)?$/i", $path)) {
    header("HTTP/1.0 404 Not Found");
    die();
}

Drupal 404, :

require_once './includes/bootstrap.inc';

( "HTTP/1.0 404 Not Found" )

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_not_found();

Now my site has successfully completed the 404th request for taxonomy / term /%, and the RSS feeds are still working. Hope this helps someone else solve this problem.

+1
source

If someone wants to use the Qyx URL Alter solution , they can also include space characters ( \s) in their URL, as shown below

if (preg_match("/^taxonomy\/term\/([0-9\s]+)(\/.*)?$/i", $path))

This prevents multiple dictionaries from accessing URLs, e.g. taxonomy / term / 1 2 3

0
source

Source: https://habr.com/ru/post/1778919/


All Articles