The paths to css/js/images in a theme look like /sites/mysite.org/theme/*

Is there a way to rewrite those paths to – let's say – /mytheme/* ?

  • htaccess rewrite – Aboodred1 Mar 30 '13 at 13:53
  • @Aboodred1 yeah but that does it just one way – redben Mar 30 '13 at 13:57
  • 2
    Can you expand a little on why you need this? That may help you get better answers or alternatives. – mpdonadio Mar 30 '13 at 14:47
  • 2
    @redben That's impossible and pointless, please don't waste your time on this. – user11153 Mar 30 '13 at 16:04
  • 2
    It's basically impossible to hide the fact that your site uses Drupal. The Drupal.settings JS var in every page is a dead give away and requires some serious re-plumbing to remove. What @user11153 is saying is that trying to implement security through obscurity is effort wasted - far better that time be spent in more productive areas – Clive Mar 30 '13 at 22:44

URL mappings can be altered with two hooks: hook_url_inbound_alter() and hook_url_outbound_alter().

hook_url_inbound_alter() is used for paths that Drupal is responding to. See drupal_get_normal_path().

hook_url_outbound_alter() is used for paths constructed by url().

Whether or not you can accomplish this will require some experimentation, as I don't know how the theme registry will complicate matters.

  • Was hoping there was a module out there that does it. Looks like I'll have to dive n code again. Thanks anyway ! – redben Mar 30 '13 at 22:02
  • 2
    Keep in mind that, with the .htaccess file Drupal uses, serving files don't involve Drupal, but the Apache server. Drupal handles only those paths that don't lead to any existing file; this means that these hooks are not invoked when the path is for an existing file. – kiamlaluno Mar 31 '13 at 0:46

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.