Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6611817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:01:14+00:00 2026-05-25T20:01:14+00:00

I am using Drupal 7 for developing a site called http://somesite.com . My requirement

  • 0

I am using Drupal 7 for developing a site called http://somesite.com. My requirement is to redirect the site to http://sub.somesite.com if a sub.somesite.com folder exists in my directory at the time of page request itself.
I have a custom module which is linked to a JavaScript file which is being called from hook_init function. This js file contains the redirection script.

But now the http://somesite.com is loaded first and then it is being redirected to http://sub.somesite.com. I need to perform the checking of file and redirecting at the time of bootstrap process itself so that the user is unaware of the site redirection.

Calling drupal_add_js function from hook_boot function throws me a fatal error (drupal_add_js() undefined).

Is there any other method to meet this requirement?

Any help would be greatly appreciated..
Thanks in advance..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:01:15+00:00Added an answer on May 25, 2026 at 8:01 pm

    This won’t work, javascript is not evaluated until the page content is built by which time it’s too late to redirect the page without anyone noticing. You will always have a delay if you use javascript…instead you want to use header('Location: somewhere') in hook_boot() if your conditions are matched.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just today I've started using Drupal for a site I'm designing/developing. For my own
My drupal site (internal) will not display the TinyMCE editor when using Google Chrome
Although I am using drupal since the D4 series, I only started developing professionally
I am developing a website with drupal 6, and using a 960 grid system
I'm developing a site in Drupal 6, and I'm going mad trying to work
Working on site development using Drupal. Using View module also. I did defined severar
I'm creating a site using drupal where I'd like to prompt my new users
I built a site using Drupal 6 recently that allows for users to submit
I am using Drupal 6. Every time I modify the CSS files, I need
I'm using Drupal 7 for a site I'm making, but when I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.