1

I'm attempting to create a custom drupal module, but I can't get clean urls to work. Clean urls have been enabled and are working everywhere else on the site.

I can access my module page using "?q=" but if I remove that and try to access it with the clean url I get a "page not found" error.

I've tried clearing the cache and rebuilding the menus using devel. I've also tried disabling and re-enabling my module.

Here's the code I have in my .module file.

/**
 * @file
 * This example demonstrates how a module can display a page at a given URL.
 */

/**
 * Implements hook_menu().
 */
function page_example_menu() {
  $items['examples/page_example/simple'] = array(
    'title' => 'Simple - no arguments',
    'page callback' => 'page_example_simple',
    'access arguments' => array('access simple page'),
  );

  return $items;
}

/**
 * Constructs a simple example page.
 *
 * @return array
 *    The render array for the simple example page.
 */
function page_example_simple() {
  return array('#markup' => '<p>' . t('Simple page: The quick brown fox jumps over the lazy dog.') . '</p>');
}
1
  • can you check this page : admin/config/search/clean-urls if clean url is enabled ? – Zakaria Elhariri Dec 18 '15 at 9:43
0

Turns out the issue was in my company's custom configuration. Certain pages are routed via Drupal while others are handled by a legacy system. All I had to do was add my module's path to our config and everything works now.

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.