403 Page to Login Redirect

Everything to do with Joomla! 1.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
drsassafras
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Fri Mar 06, 2009 3:43 pm

403 Page to Login Redirect

Postby drsassafras » Tue Mar 10, 2009 1:45 am

I wanted to share this with the joomla community. When members visit an article when not logged in they get the very unhelpful 403 access restricted page. Its an easy template modification to move them to the login screen, but then they don't end up at the article they wanted when they login.

Here are step by step instruction on how to modify your default 1.5.9 joomla install to longin members and then send them to the page they requested.

I fumbled through most of it, so the code could probably be improved. If you can improve it, Post it here! Hopefully joomla will incorporate something like this into its default install.

First. Modify the /templates/system/error.php.

Find the line:
defined( '_JEXEC' ) or die( 'Restricted access' );


and the place the following code after the code above:

$ReferTo = $_SERVER['REQUEST_URI'];
$ReferTo = base64_encode($ReferTo);

if ($this->error->code = '403') {
header('Location:index.php?option=com_user&view=login&ReferTo='.$ReferTo); die();
}


Second. Modify the /components/com_user/views/login/tmpl/default_login.php

Search for:
<input type="hidden" name="return" value="<?php echo $this->return; ?>" />


And replace it with:
<input type="hidden" name="return" value="<?php if ($_GET['ReferTo']) echo $_GET['ReferTo']; else echo $this->return; ?>" />


There you have it. You should be all modified! I have included the 2 files in this message, so you can just overwrite the last ones as well. It might be easier then opening and modifying the code. But beware you are using the same version of joomla. ONLY modify the code yourself if you are using a different version.

Dr. Sassafras
You do not have the required permissions to view the files attached to this post.

dreteh
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Mar 29, 2009 11:02 pm

Re: 403 Page to Login Redirect

Postby dreteh » Sun Mar 29, 2009 11:35 pm

Wow, your post is very helpful. I made the change and it works great.
Thanks for your sharing.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 33144
Joined: Sat Apr 05, 2008 9:58 pm

Re: 403 Page to Login Redirect

Postby Webdongle » Mon Mar 30, 2009 12:36 am

Is removing
defined( '_JEXEC' ) or die( 'Restricted access' );
such a good ides ?

It is put on Joomla files for a reason.

My mistake, just re-read it, i think i will need to lay off the booz before i read the posts. :-[
Last edited by Webdongle on Mon Mar 30, 2009 2:23 pm, edited 1 time in total.

PastorAarn
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Thu Mar 05, 2009 8:18 pm

Re: 403 Page to Login Redirect

Postby PastorAarn » Mon Mar 30, 2009 1:22 am

I have been struggling with this issue for weeks and your simple solution fixed it for me in minutes. Thank you very much.

drsassafras
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Fri Mar 06, 2009 3:43 pm

Re: 403 Page to Login Redirect

Postby drsassafras » Mon Mar 30, 2009 11:43 am

Webdongle wrote:Is removing
defined( '_JEXEC' ) or die( 'Restricted access' );
such a good ides ?\


Please read the instructions more closely. I specify putting the code after this line. Removing the code would allow this file to be called without being logged in... Now if it was a public access file, then I don't see the problem in it... But I am not really an expert and its all sort of off topic anyhow. Yes. Don't remove the code.

drsassafras
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Fri Mar 06, 2009 3:43 pm

Re: 403 Page to Login Redirect

Postby drsassafras » Mon Mar 30, 2009 12:24 pm

PastorAarn wrote:I have been struggling with this issue for weeks and your simple solution fixed it for me in minutes. Thank you very much.


Yes, it took me the better part of a day to figure out how to do this. Glad I can save other people some time.

On another note, I just took at look at the upgrade package from joomla 1.5.9 to 1.5.10. The files we are working with here do not appear to be changed in 1.5.10. So, the instructions and the upgrade files should both work for 1.5.10 as well as 1.5.9.

Now, to be phenomenological about this, we need to see the file overwrites in action in order to be sure. If anyone can confirm that the files posted here do in fact work in 1.5.10, I am sure there would be other people who would appreciate the confirmation.

User avatar
leolam
Joomla! Master
Joomla! Master
Posts: 18271
Joined: Mon Aug 29, 2005 10:17 am
Location: Netherlands/ UK/ S'pore/Jakarta/ North America
Contact:

Re: 403 Page to Login Redirect

Postby leolam » Tue Mar 31, 2009 2:23 am

Webdongle wrote:My mistake, just re-read it, i think i will need to lay off the booz before i read the posts.
Sounds like a plan to me! 8)
Celebrating 12-Years of Professional Joomla Support Services
- Joomla Professional Support:https://gws-desk.com -
- Joomla Specialized Hosting Solutions:https://gws-host.com -
- Member Joomla Bug Squad & J-CMS Release Team

izabela
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Apr 01, 2009 2:36 pm

Re: 403 Page to Login Redirect

Postby izabela » Wed Apr 01, 2009 8:43 pm

Hi,

Thank you very much drsassafras, the solution is great ;D
I did upgrade to 1.5.10 today and it looks it works as well.

Best regards,
Izabela

o2plus2h
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Fri Jul 04, 2008 5:32 pm

Re: 403 Page to Login Redirect

Postby o2plus2h » Sun Apr 19, 2009 5:43 pm

Is there a way to do this when using community builder?

generator11
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Thu Nov 27, 2008 10:59 pm

Re: 403 Page to Login Redirect

Postby generator11 » Thu Apr 30, 2009 2:08 pm

Just tried this with J1.5.10 and CB1.2 and it did not work. Worth a try though.

Will25
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Thu May 21, 2009 3:53 am

Re: 403 Page to Login Redirect

Postby Will25 » Tue Jun 09, 2009 4:58 am

With the helpful hints that I get at this forum I will never really learn Joomla or PHP...
This "small" change really makes a difference. It makes my amateur page seem much more professional. A visitor can save a page to his favorites and later just click it - sign in and go right to the page. Just like a real web page! lol - thanks.

User avatar
Kualaho
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 140
Joined: Sat Apr 18, 2009 9:38 pm
Location: UK
Contact:

Re: 403 Page to Login Redirect

Postby Kualaho » Fri Jun 12, 2009 12:10 pm

Thanks. I posted similar problem several months ago without help. until a member posted this link. I will give it a try.

dumini
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 112
Joined: Thu Jan 22, 2009 4:10 pm

Re: 403 Page to Login Redirect

Postby dumini » Wed Jun 17, 2009 3:37 pm

Very good! I haven't thoroughly tested it but it worked the first time. Thank you.

Can't believe this is not a default thing here.

a2purn
Joomla! Intern
Joomla! Intern
Posts: 90
Joined: Fri Feb 27, 2009 9:27 am
Contact:

Re: 403 Page to Login Redirect

Postby a2purn » Fri Jul 17, 2009 8:33 pm

this nice sharing has been long time but it very helpfull, thank you very much :D

jazzking2001
Joomla! Explorer
Joomla! Explorer
Posts: 362
Joined: Sun Sep 02, 2007 12:50 am
Contact:

Re: 403 Page to Login Redirect

Postby jazzking2001 » Thu Aug 06, 2009 1:30 am

i will try it now
it seems like a solution
http://www.neocrisis.com/ - What will you find Next?

jazzking2001
Joomla! Explorer
Joomla! Explorer
Posts: 362
Joined: Sun Sep 02, 2007 12:50 am
Contact:

Re: 403 Page to Login Redirect

Postby jazzking2001 » Thu Aug 06, 2009 2:44 am

um have the latest Joomla 1.5.13
and i dont c
components/com_user/views/login/tmpl/default_login.php

any ideas?

also about part one of directions
i think that the link to login is different now
for my site its

http://www.neocrisis.com/component/comprofiler/login
i dont know its the same or not
http://www.neocrisis.com/ - What will you find Next?

jerryjurden
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Wed Aug 19, 2009 7:07 pm

Re: 403 Page to Login Redirect

Postby jerryjurden » Thu Aug 20, 2009 3:40 am

Wow, this worked, thanks so much!

RANT: It's REDICULOUS that a product this mature does not do this by default! It's utterly absurd that I have to hack the code to make this behave the way it should!!!!!

jazzking2001
Joomla! Explorer
Joomla! Explorer
Posts: 362
Joined: Sun Sep 02, 2007 12:50 am
Contact:

Re: 403 Page to Login Redirect

Postby jazzking2001 » Thu Aug 20, 2009 4:10 am

jazzking2001 wrote:um have the latest Joomla 1.5.13
and i dont c
components/com_user/views/login/tmpl/default_login.php

any ideas?

also about part one of directions
i think that the link to login is different now
for my site its

http://www.neocrisis.com/component/comprofiler/login
i dont know its the same or not

any idea?
http://www.neocrisis.com/ - What will you find Next?

Beatleuk
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Tue Sep 22, 2009 5:57 am

Re: 403 Page to Login Redirect

Postby Beatleuk » Mon Sep 28, 2009 11:20 am

Most awesome posting and it did exactly what I wanted it to do.

One further question, is there anyway to make the login form popup in front of the (blacked out) page they were on trying to access the restricted link from? to look something like this:
Image

Thanks for a great solution!

sw373
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Oct 09, 2009 2:25 pm

Re: 403 Page to Login Redirect

Postby sw373 » Fri Oct 09, 2009 2:35 pm

Great post! I'm using 1.5.14 and the redirect goes to the login page as it should but it returns to the home page rather than the requested page. Any ideas on how I can get it to go to the requested page rather than the home page?

zoomlanski
Joomla! Intern
Joomla! Intern
Posts: 81
Joined: Thu Oct 23, 2008 10:59 am

Re: 403 Page to Login Redirect

Postby zoomlanski » Sat Oct 31, 2009 2:07 am

Generator11, o2plus2h:

I made it work with Community Builder. I think I have 1.2 Stable.
Running Joomal Version 1.5.14

Upload the Error file in /templates/system - File still the same no change with this version

Change

if ($this->error->code = '403') {
header('Location:index.php?option=com_user&view=login&ReferTo='.$ReferTo); die();
}

if ($this->error->code = '403') {
header('Location:index.php?option=com_comprofiler&task=login&ReferTo='.$ReferTo); die();

Wow, this stuff is starting to make sense to me.
If someone can post this in CB forums that would be great.

Joomla rocks!
Thanks drsassafras for getting it started!


Tim

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 33144
Joined: Sat Apr 05, 2008 9:58 pm

Re: 403 Page to Login Redirect

Postby Webdongle » Sat Oct 31, 2009 6:13 pm

sw373 wrote:Great post! I'm using 1.5.14 and the redirect goes to the login page as it should but it returns to the home page rather than the requested page. Any ideas on how I can get it to go to the requested page rather than the home page?


Try making the Menu Item to the page Reistered ?

jazzking2001
Joomla! Explorer
Joomla! Explorer
Posts: 362
Joined: Sun Sep 02, 2007 12:50 am
Contact:

Re: 403 Page to Login Redirect

Postby jazzking2001 » Sun Nov 01, 2009 8:21 am

what file do we need to edit?
i am looking at templates/system/error.php but that page is for when page links do not work ect
http://www.neocrisis.com/ - What will you find Next?

Beatleuk
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Tue Sep 22, 2009 5:57 am

Re: 403 Page to Login Redirect

Postby Beatleuk » Sun Nov 01, 2009 10:55 am

jazzking2001 wrote:what file do we need to edit?
i am looking at templates/system/error.php but that page is for when page links do not work ect


jazzking, the instructions are very clear and if you follow exactly what drsassafras says it works. 403 is an error, its a link that cannot be accessed unless you have the correct privledges. If you're not wanting what this post instructs then you should look elsewhere or post what you are really looking for but this does exactly what it says!

SteinerPDP
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Jul 29, 2009 9:45 am
Contact:

Re: 403 Page to Login Redirect

Postby SteinerPDP » Sun Nov 08, 2009 3:41 pm

zoomlanski: worked well for CB ... just don't forget the "}" at the end

... however, after the log-in I get directed to the front page and not to the article .. any ideas?

Crash23
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sat Nov 21, 2009 4:04 pm

Re: 403 Page to Login Redirect

Postby Crash23 » Sat Nov 21, 2009 4:08 pm

Can't make it work in version 1.5.14 (with no CB installed)

Can anyone offer asistance?

Thanks.

.............................................

Update, I disbled "Search Engine Friendly URLs" and it now redirects to the homepage. Not ideal as I would prefer search engine friendly URLs.

Any thoughts anyone ... thanks.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 33144
Joined: Sat Apr 05, 2008 9:58 pm

Re: 403 Page to Login Redirect

Postby Webdongle » Sat Nov 21, 2009 8:50 pm

There is an alternative...

* Create a separate menu that is not Activated.
* In that menu place a link to the page that is members only and set it Registered.
* In your main menu place a link to the link in the inactive menu and leave it set Public.

The users will see the link in your main menu. When that link is clicked by non logged in members the 'Please login..' will be displayed. After logging in the user will be directed to the target page.

Crash23
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sat Nov 21, 2009 4:04 pm

Re: 403 Page to Login Redirect

Postby Crash23 » Sun Nov 22, 2009 9:41 am

Thanks Webdongle,
Eventually got there. I initially used "Alias" on the wrong menu. All sorted now ... thanks again.

a2purn
Joomla! Intern
Joomla! Intern
Posts: 90
Joined: Fri Feb 27, 2009 9:27 am
Contact:

Re: 403 Page to Login Redirect

Postby a2purn » Fri Nov 27, 2009 4:50 pm

Hello,

I know my problem may be different from the cases above, but please help.
Is it possible to the default joomla login to be redirect to https? and if can be please any one help me... :( :-\
because I have tried using module parameters in the login does not work for specific login page only, because after redirected to https all the links changed to https.

Thanks,

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 33144
Joined: Sat Apr 05, 2008 9:58 pm

Re: 403 Page to Login Redirect

Postby Webdongle » Fri Nov 27, 2009 5:27 pm

a2purn wrote:Hello,

I know my problem may be different from the cases above, but please help.
Is it possible to the default joomla login to be redirect to https? and if can be please any one help me... :( :-\
because I have tried using module parameters in the login does not work for specific login page only, because after redirected to https all the links changed to https.

Thanks,

Do you have SSL ?


Return to “Templates for Joomla! 1.5”

Who is online

Users browsing this forum: No registered users and 9 guests