开发者

Redirection in drupal 7

I am using Drupal 7 for developing a site called http://somesite.com. My requirement is to redirect the site to http://sub.somesi开发者_运维技巧te.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..


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜