page redirection

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
smiley
Regular
Posts: 11
Joined: Mon Jul 11, 2005 8:43 am

page redirection

Post by smiley »

hi all,
I have been using serendipity blog recently and found it to be a great tool. But I'm stuck with one problem. As soon as I open the website, I want it to be redirected to the login page directly without showing the index page. In brief, This redirection should happen whenever the user is not logged in............I've tried it with some headers and html codes in the index page. I got it to work but don't know why there is some delay before redirection...........How can I avoid that delay???
Please help me solve this !!! :oops:
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: page redirection

Post by garvinhicking »

In your index.php try this:

After this line:

Code: Select all

header('Content-Type: text/html; charset='. LANG_CHARSET);
add this:

Code: Select all

if (serendipity_userLoggedIn() == false) {
header('Location: ' . $serendipity['baseURL'] . '/serendipity_admin.php');
}
that is the fastest way I know of.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
smiley
Regular
Posts: 11
Joined: Mon Jul 11, 2005 8:43 am

page redirect

Post by smiley »

hi Garvin,
Thanks a ton for ur instant reply. Your code is fine and we could get the page without delay....but it gave rise to new problem. Our page layout has been changed. There is no template behind and only plain text is being displayed!! what do we do now? :cry:
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: page redirect

Post by garvinhicking »

Don't know. I'll need your URL to see what you mean. Most probably your CSS is not loaded because it also requires that you're logged in. Maybe you'll need to change the code I told you to not redirect if CSS is requested (see index.php below for the IF-clause that checks if CSS is requested).

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
smiley
Regular
Posts: 11
Joined: Mon Jul 11, 2005 8:43 am

page redirect

Post by smiley »

hi Garvin,
Thanku very very much for your valuable help.
My redirection is working very fine now.
:D
Post Reply