Registered content redirect not working

This forum is for reporting bugs in Joomla!. Please don't report problems with extensions in here.
ghobbs
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Tue Jul 31, 2007 10:06 am

Registered content redirect not working

Post by ghobbs » Sun Mar 02, 2008 11:54 am

I get the below 404 error message when trying to access registered content (when logged out)

Code: Select all

403 - You are not authorised to view this resource.
You may not be able to visit this page because of:

an out-of-date bookmark/favourite
a search engine that has an out-of-date listing for this site
a mistyped address
you have no access to this page
The requested resource was not found.
An error has occurred while processing your request.
Please try one of the following pages:

Home Page
If difficulties persist, please contact the System Administrator of this site.
http://www.ghobbs.eu/index.php?option=c ... d&Itemid=6

Surely users should be redirected to a friendly logon page when they try and access content that's registered? I've searched the forum and there are plenty of reports of this issue but no solutions.

I have tried all variations of SEO Settings with no success. In desperate need of help.

Telethra
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Tue Mar 04, 2008 10:49 pm

Re: Registered content redirect not working

Post by Telethra » Thu Mar 20, 2008 6:35 pm

I'm glad I'm not the only one having this problem...

If unregistered users try to access Registered content, it should take them to a login page at the very least! This ugly error message screen is very discouraging.

Is there any way to change this? A Plug In or configuration setting - SOMETHING?!!


Thanks.

thedroop
Joomla! Apprentice
Joomla! Apprentice
Posts: 45
Joined: Thu Oct 18, 2007 8:50 am

Re: Registered content redirect not working

Post by thedroop » Wed Mar 26, 2008 11:35 pm

I ALSO HAVE THIS PROBLEM!!!!!

It is Joomla! It must be, Ive done so much testing, It even does this with just bare joomla 1.5.2

This is ssooo bad for me because so many people link my site around on forums, sites & etc...

now when people go to those links, it goes to a 404 page, not a "you need to register page"

so bad for me :( Ill lose so many new possible users

jansen
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Mar 12, 2008 10:12 pm

Re: Registered content redirect not working

Post by jansen » Fri Mar 28, 2008 11:53 pm

I've tried every module / plugin / component for SEF/SEO like sh404sf, smarty (latest version conflicts with other plugins it appears), etc.

sh404sf is probably the best alternative, however having to put the system into legacy, and having it break page-breaks by default is annoying. You get to have a 404 error page, but isn't compatible with chronoForms, 4.6.2 of phoca, and some custom plugins.

It would be great if there was an option to select from a drop down list an article to act as the error 404 page.
Actually, it's mandatory. Why isn't there one? It's more needed than having friendly URL's. Why??

I came from Drupal for the wine and beer, and all I see so far are empty glasses and kegs. Where did all the fun go? Better yet, wasn't a 404 custom page possible in Mambo? :eek:

Cheers
:pop :geek:

Gatsu000
Joomla! Apprentice
Joomla! Apprentice
Posts: 29
Joined: Tue Feb 19, 2008 7:25 pm

Re: Registered content redirect not working

Post by Gatsu000 » Mon Mar 31, 2008 3:47 am

We also have this problems on our site.

The problem didn't start until we had a different domain point to the Joomla! folder and started to use that one.
Here is the site http://tserverhq.com

We need to have our customers register to use our products the sooner this gets fixed or a problems is posted the better. Thank you.

aschweitzer
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sat Mar 29, 2008 11:11 am

Re: Registered content redirect not working

Post by aschweitzer » Tue Apr 01, 2008 9:47 am

I have the same problem, however in 1.0.x there was an article which prompted the users to login

goangus
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Apr 03, 2008 11:58 am

Re: Registered content redirect not working

Post by goangus » Thu Apr 03, 2008 12:05 pm

I am quite new to Joomla and this is a hack more than a solution but it works for me..
You should have an error.php document in your template foder where the custom error page is defined.
All you need to do is add a small piece of code in the head section of this document:

Code: Select all

<script language="javascript" type="text/javascript">
//<![CDATA[	
<?php if($this->error->code == '403'){ ?>
	window.location = "http://www.yoursite.com/"
<?php } ?>
//]]>
</script>
Obviously change yoursite.com appropriately..
Hope this offers some sort of solution to those of you who are stuck

microsfot
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Fri Jan 26, 2007 4:55 pm

Re: Registered content redirect not working

Post by microsfot » Thu Apr 03, 2008 1:08 pm

goangus wrote:I am quite new to Joomla and this is a hack more than a solution but it works for me..
You should have an error.php document in your template foder where the custom error page is defined.
All you need to do is add a small piece of code in the head section of this document:

Code: Select all

<script language="javascript" type="text/javascript">
//<![CDATA[	
<?php if($this->error->code == '403'){ ?>
	window.location = "http://www.yoursite.com/"
<?php } ?>
//]]>
</script>
Obviously change yoursite.com appropriately..
Hope this offers some sort of solution to those of you who are stuck
Good! It works! But someone have a code joomla hack?

Cosimo Piovasco
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Apr 14, 2008 2:28 pm

Re: Registered content redirect not working

Post by Cosimo Piovasco » Mon Apr 14, 2008 3:33 pm

Hi all:

Has anybody found the right solution?

I´ve the same problem, no way to get rid of 404 error.

Thanks in advance and sorry about my english.

User avatar
Replika
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Fri Apr 14, 2006 4:06 pm

Re: Registered content redirect not working

Post by Replika » Sat May 24, 2008 9:26 am

Little surprise (and disappointed) that the developers do not care about this issue.
First, I think I do wrong in configuration/setting, but after searching forum, I have not see a right solution from developers.
someone have a code joomla hack?
you can check my patch for Joomla 1.5.3 (use at your own risk)
http://www.mediafire.com/?zh25moumbzz

I add a funtion into JFactory: if user logged in, the error page will apprear, if not, redirect to login.
And change a bit in components\com_content\models\article.php, category.php, section.php to point to this function.
Last edited by Replika on Wed May 28, 2008 3:54 am, edited 1 time in total.

shahpound
Joomla! Apprentice
Joomla! Apprentice
Posts: 36
Joined: Sat Jan 05, 2008 10:23 pm
Location: Cambridge, MA

Re: Registered content redirect not working

Post by shahpound » Tue May 27, 2008 12:15 am

Replika - Am I correct in assuming the following is true: Your solution does not redirect the user to the original content item they were attempting to access? I thinK I will modify the patch to do this. I want to start with your latest version so let me know if you have updates. Thx.

User avatar
Replika
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Fri Apr 14, 2006 4:06 pm

Re: Registered content redirect not working

Post by Replika » Tue May 27, 2008 1:18 am

shahpound wrote:Replika - Am I correct in assuming the following is true: Your solution does not redirect the user to the original content item they were attempting to access? I thinK I will modify the patch to do this. I want to start with your latest version so let me know if you have updates. Thx.
If a guest go to a registered article, my patch will let him to login page. And after login successfully, it will direct to that article (your original content)

reluna
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue May 27, 2008 4:25 pm

Re: Registered content redirect not working

Post by reluna » Tue May 27, 2008 5:35 pm

Hi, I have the same problem, and I'm very surprised that it hasn't been fixed, I'll try Replika's hack....

Another "problem" I've found related to this one is that I can't show links to restricted content to unlogged users.... so when they clic one of them it takes them to the login page... this doesn't look that complicated, is it?

cvb5492
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sun Jun 01, 2008 7:37 am

Re: Registered content redirect not working

Post by cvb5492 » Sun Jun 01, 2008 7:44 am

Morning!

I tried the fix from Replika. At first it was not working, but figured it out when looking at the code. I started off with an article for which access level was set to registered. Code however works on the event an article is public but its section and/or category are set to registered. Tried it again and then the fix worked.

Thanks Replika!


Cynthia

tog000
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Jul 15, 2008 6:29 pm

Re: Registered content redirect not working

Post by tog000 » Wed Jul 16, 2008 7:20 pm

Thanks for the fix Replika!
Anyway, to fix the last issue: Registered only articles.
It was fixed by replacing the following code in the file components/com_content/views/article/view.html.php:

Replace:

Code: Select all

return JError::raiseError( 404, JText::sprintf( 'Article # not found', $id ) );
With:

Code: Select all

               if($id!=0){
                                 JFactory::loginRequest();  //Viet
                        }else{
                                return JError::raiseError( 404, JText::sprintf( 'Article # not found', $id ) );
                        }
And of course apply the patch that Replika provided.

Thanks, and hope this can save you some time.

thedroop
Joomla! Apprentice
Joomla! Apprentice
Posts: 45
Joined: Thu Oct 18, 2007 8:50 am

Re: Registered content redirect not working

Post by thedroop » Tue Jul 29, 2008 12:14 am

Using Joomla 1.5.4

HAVE HAD THE EXACT PROBLEM I HAVE TRIED EVERYTHING!!!!

At least I feel better I am not the only one- I thought I totally messed something up somewhere

User avatar
AZTommyB
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Wed May 03, 2006 2:41 am
Location: Prescott, Arizona
Contact:

Re: Registered content redirect not working

Post by AZTommyB » Sat Aug 23, 2008 12:05 am

Same problem. 404 error when registered content is accessed by a "guest".
Running Joomla 1.5.6

ADMINISTRATORS......DEVELOPERS......WHERE ARE YOU ON THIS???

Can someone official at least weigh in on it?? Acknowledge that there is a problem?

Thank you.

chachig
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Jul 21, 2008 4:12 pm

Re: Registered content redirect not working

Post by chachig » Wed Aug 27, 2008 11:04 pm

Just so people are aware the issue is occurring for me ass well and hopefully my setup helps show it isn't a server configuration issue.

I have a primary Joomla site located at http://www.sitename.com/ at 1.5.6 and I have a Joomla site created at http://www.sitename.com/submenu which is 1.5.2, the site located in the submenu folder does not have the issue with the 404 page showing when trying to access registered content and you are not logged in but the primary site in the root folder does have the issue.

chachig
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Jul 21, 2008 4:12 pm

Re: Registered content redirect not working

Post by chachig » Wed Aug 27, 2008 11:27 pm

I got more information for everyone.

I have found that you don't get the 404 if you set both the menu item to "registered" and the article to "registered", but of course if you do that no one sees the link until they log in. But if you manually go to the link in the address bar you are prompted to log in.

Example:
http://www.sitename.com/index.php?optio ... 4&Itemid=2

It seems like Joomla doesn't know how to handle the request if only one of the items is set to "registered" so hopefully this helps with the next patch.

This would explain why I have the issue on the sub site and not the root because I was just cutting and pasting the link to the item on the sub site not actually go through a menu item.

stevetsi
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Sun Jan 22, 2006 11:21 pm
Location: Annapolis, MD
Contact:

Re: Registered content redirect not working

Post by stevetsi » Thu Aug 28, 2008 9:15 pm

Add me to the list of complainers...

I can confirm that the issue is due to different permission levels on menu items and pages linked to by them.

I've been able to get around the issue by setting the menu items to the same permission level as the pages. BUT, as has been stated before, this ends up hiding the links from the visitors.

So, this is a BUG.

I'm not sure if this is related, but I can't seem to create a custom page link to the login form component. I create the menu item, associated it with the login component, assign module positions to it, but all I seem to get is a plain login page. What gives?

I can't believe how much time I've wasted trying to resolve this stupid issue... I still love Joomla, though.

videodude
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Sat Aug 09, 2008 4:21 pm

Re: Registered content redirect not working

Post by videodude » Sun Sep 07, 2008 12:26 am

I'm experiencing the same problem. I tried the php fix that replika recommended, but it didn't work. To be fair I probably did something wrong since I know exactly zero php. Hope someone can post an easier fix and one that doesn't require php coding.

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Registered content redirect not working

Post by mcsmom » Mon Sep 08, 2008 8:45 pm

It's not really a bug but actually this is a really complicated issue that has been addressed in part by some patches that are in the current SVN and some that are pending in the tracker.

Search for 404 (sorry can't link joomlacode is so slow today)
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

stevetsi
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Sun Jan 22, 2006 11:21 pm
Location: Annapolis, MD
Contact:

Re: Registered content redirect not working

Post by stevetsi » Mon Sep 08, 2008 11:02 pm

The following code contains a modification I made to the loadArticle function in J1.5.6 from article.php:

(joomla_root)/components/com_content/models/article.php
-->beginning at line 556 (assuming no other hacks)

IMPORTANT: The code modifications below are aimed at users of JACLplus pro because of the the reference to JACL subgroups. ALSO, you must implement SEF urls so that the url redirection can be properly created.

The key to the functionality of this hack is the function JURI::getInstance. Used in conjunction with base64 encoding, I assembled a method for capturing the current url request, encoding it, and returning in the form:

http://www.yoursite.com/Log-in.html?ret ... TERSGOHERE

This creates a redirect to the login page which, most importantly, redirects you to the originally requested page, assuming your login credentials provide suffecient access rights.

Remember, this is just a temporary hack, though it does work quite well.

Code: Select all

	/**
	 * Method to load content article data
	 *
	 * @access	private
	 * @return	boolean	True on success
	 * @since	1.5
	 */
	function _loadArticle()
	{
		global $mainframe;

		if($this->_id == '0')
		{
			return false;
		}

		// Load the content if it doesn't already exist
		if (empty($this->_article))
		{
			// Get the page/component configuration
			$params = &$mainframe->getParams();

			// If voting is turned on, get voting data as well for the article
			$voting	= ContentHelperQuery::buildVotingQuery($params);

			// Get the WHERE clause
			$where	= $this->_buildContentWhere();

			$query = 'SELECT a.*, u.name AS author, u.usertype, cc.title AS category, s.title AS section,' .
					' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
					' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug,'.
					' g.name AS groups, s.published AS sec_pub, cc.published AS cat_pub, s.access AS sec_access, cc.access AS cat_access '.$voting['select'].
					' FROM #__content AS a' .
					' LEFT JOIN #__categories AS cc ON cc.id = a.catid' .
					' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = "content"' .
					' LEFT JOIN #__users AS u ON u.id = a.created_by' .
					' LEFT JOIN #__groups AS g ON a.access = g.id'.
					$voting['join'].
					$where;
			$this->_db->setQuery($query);
			$this->_article = $this->_db->loadObject();

//			if ( ! $this->_article ) {
//			return false;
//			}
		//Modification to resolve 404 redirect error from registered page
		//Prevent from throwing 404 and redirect to any desired page e.g. login/register or content page
			if ( ! $this->_article ) {
			//Retrieve content access level
			$user =& JFactory::getUser();         
			$myquery = "SELECT `access` FROM #__content WHERE `id`=". (int) $this->_id;
			$this->_db->setQuery($myquery);
			$myrow = $this->_db->loadObject();
                                                                 //Retrieve JACLplus access levels
				 defined('_JACL');
				 $user = &JFactory::getUser();
				 $gids = $user->get( 'jaclplus', '0' );
				 $myJACLGids = explode(",", trim($gids));
			
			if (in_array($myrow->access , $myJACLGids)) {
			return true;
			} else {
			//Here we retrieve the url instance, encode it, and assemble 
                                                //the url for the login page with the redirect appended to it.
			$uri =& JURI::getInstance();
			$url = $uri->getPath();
			$url = base64_encode($url);
			$mainframe->redirect("Log-in.html?return=".$url);
			exit();
			}
			}
		//End Modification to resolve 404 redirct error from registered page


			if($this->_article->publish_down == $this->_db->getNullDate()) {
				$this->_article->publish_down = JText::_('Never');
			}

			// These attributes need to be defined in order for the voting plugin to work
			if ( count($voting) && ! isset($this->_article->rating_count) ) {
				$this->_article->rating_count	= 0;
				$this->_article->rating			= 0;
			}

			return true;
		}
		return true;
	}

evdboogaard
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Thu Nov 09, 2006 11:38 pm
Location: Netherlands

Re: Registered content redirect not working

Post by evdboogaard » Tue Sep 09, 2008 9:41 pm

Here's my solution for custom error messages:
  • Create for each error message an article (aka content item). Preferably it should contain images with text on it so they won't show up with their content when a user does a search (thanks Amy for pointing this out).
    I named the pages after the error numbers and the message that Joomla shows.
  • Create a menu (called hidden menu or something like that) and create a module for it, but do NOT publish it.
  • Add for each article containing the error message a link on this hidden menu, name them 403 or 404, etc.
  • Copy error.php from the /templates/system directory to your template directory
  • Edit this error.php and add just before the head tag the following:

    Code: Select all

    <?php
    $errormessages= array (403, 404);
    if (in_array($this->error->code, $errormessages)) {
        echo "<meta http-equiv=\"refresh\" content=\"0;URL=/" . $this->error->code . "\" />";
    }
    ?>
    Note: in the code above, add your menu link names in the array of error messages.
Now, what this does is show the regular error message and then immediately refresh the page and show your customized error message. It shows the proper error messages for the search engines (you can check it here, yet displays your visitor with a decent page.

Maybe it's not the most beautiful solution, but it's simple, easy and it works. :D


Here's an alternative (adapted from guywithcable's solution for a custom 404)
after "defined( '_JEXEC' ) or die( 'Restricted access' );" add

Code: Select all

 $errormessages = array (403, 404);
	if (in_array($this->error->code, $errormessages)) {
		echo file_get_contents("http://www.yourwebsite.com/". $this->error->code);
	}	
   
    else
    {
And at the bottom, after "</html>" add

Code: Select all

<?php
    }
    ?>

thedroop
Joomla! Apprentice
Joomla! Apprentice
Posts: 45
Joined: Thu Oct 18, 2007 8:50 am

Re: Registered content redirect not working

Post by thedroop » Wed Sep 10, 2008 3:31 am

1.5.7 is out, that has been fixed :D

evdboogaard
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Thu Nov 09, 2006 11:38 pm
Location: Netherlands

Re: Registered content redirect not working

Post by evdboogaard » Wed Sep 10, 2008 7:56 am

Well, it was a nice excercise.... :laugh:

stevetsi
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Sun Jan 22, 2006 11:21 pm
Location: Annapolis, MD
Contact:

Re: Registered content redirect not working

Post by stevetsi » Thu Sep 11, 2008 12:51 am

...hmm

I tested with J1.5.7 and I am still experiencing the same problem - no redirection to login page (with encoded url that leads back to originally requested page).

User avatar
yerg
Joomla! Guru
Joomla! Guru
Posts: 998
Joined: Thu Aug 18, 2005 12:22 pm
Location: Ballarat, Australia
Contact:

Re: Registered content redirect not working

Post by yerg » Sat Sep 13, 2008 10:07 am

Hmmm I figured I could modify the error.php page however I like

One example I've done is here

That file is templates/system/error.php

This site doesn't have registration but you could still modify that page however you like.

May be even put a php auto redirect to your customised login/rego page if you want.
We cannot become what we need to be ... by remaining what we are

evdboogaard
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Thu Nov 09, 2006 11:38 pm
Location: Netherlands

Re: Registered content redirect not working

Post by evdboogaard » Sat Sep 13, 2008 11:29 am

Redirecting a page doesn't return the right error code for a/o search engines ;)

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Registered content redirect not working

Post by mcsmom » Sat Sep 13, 2008 3:33 pm

Yup, that's the next, much more complicated phase of this.

Suggestions welcome for sure.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.


Locked

Return to “Joomla! 1.5 Bug Reporting”