I have create 2 angular app into drupal 7 like


example.com is my main site. So, when I set html5 pushstate enable for removing hash in angular apps, I got nobase error from angularjs. Coz,

<base href="">

require for enable angularjs html5 pushstate.

My question is, since i have multiple angualr app in this drupal site, how can i dynamically add conditional base url for "/app1" and "app2" ?

anybody can help me? Waiting for response. Thanx.

  • nobody here to help me?
    – Tazim
    Mar 1, 2016 at 11:22

1 Answer 1


Add base element to your sites theme template file:

YOUR_THEME_NAME_preprocess_html(&$variables, $hook) {
    $url = 'default';// default url
    if($application1) {// your condition for app1
      $url = 'app1';
    } elseif($application2) {// your condition for app2
    $url = 'app2';
    $data = array(
      '#tag' => 'base',
      '#attributes' => array(
      'href' => $url,
    drupal_add_html_head($data, 'base_href');

Put it into your template.php

Ref: https://stackoverflow.com/a/35725528/3770000

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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