1

I created a module with a hook_menu() to redirect every $items[%node] to drupal_goto('<front>'). Is it possible to do the same for every alias path and how would I do that?

The background is that it's a one-pager with all nodes displayed only on the <front> page. No single node should be viewed. Nevertheless every single node has a Facebook Like Button and so has to be like-able/share-able with Facebook. But that's another story, on the whole.

  • Sounds like you're about to commit SEO-suicide...I'm probably just not getting it but could you explain what you're trying to do in a bit more detail? If you're forwarding all node pages onto the front page, the individual Facebook like buttons will never be available to anyone... – Clive Jun 5 '13 at 9:35
  • The individual Facebook Like Button is made available through the view by adding a field for content: pathand rewrite the result with the Facebook div and inserting a path token as URL. – leymannx Jun 5 '13 at 9:39
  • 3
    Might I suggest a different approach? Install Rabbit Hole to return a 404 on the full node pages, and set the path of the custom 404 to the front page. That should have exactly the same effect, with a lot less mess – Clive Jun 5 '13 at 9:50
  • 1
    Yep @koivo Disability Discrimination Act/Section 504/other applicable local law...They're extraordinarily rare in my experience, but it's your head on the block if you fail to advise. Crazy world we live in. – Clive Jun 5 '13 at 10:12
  • 1
    What @Clive says, plus if you plan to ever be able to cooperate with any kind of government (even at local level) in European Union, you have to have AA accessibility level as defined by w3c. If you will get any income from cooperating with tax-funded institutions it opens a whole new law requirements labyrinth for you. I believe in other areas it's similar now. Side effect: good SEO required by law ;) – Mołot Jun 5 '13 at 10:50
0

Using the Rules module you can implement a rule that looks like so:

{ "rules_redirect_all_node_aliases" : {
    "LABEL" : "Redirect all node aliases",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "text_matches" : {
          "text" : [ "site:current-page:path" ],
          "match" : "node\/\\d+$",
          "operation" : "regex"
        }
      }
    ],
    "DO" : [
      { "redirect" : { "url" : "my_homepage" } }
    ]
  }
}

It will redirect any path starting with node/ to a path named my_homepage (adapt that path to fit your homepage path).

To experiment with this rule in your own site, just copy the entire Rules code above, and paste it in a new Rule in your own site, created via the "Import" function.

Note: A variation of this rule could be to replace the Rules Condition with something like "if the current path is not my_homepage" (in which case the same Rules Action will redirect to my_homepage.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.