redirect to subdomain on login?

Discussion forum for MOD Writers regarding MOD Development.
Locked
dsm phreak
Registered User
Posts: 77
Joined: Fri Oct 15, 2010 3:15 am

redirect to subdomain on login?

Post by dsm phreak » Mon Jun 25, 2012 9:52 pm

Alright guys and gals, I'm just about ready to rip my hair out...lol. I've been digging for the past several hours trying to find a way to do this and I've stumbled across several threads, but none of which seem to have a straight forward answer...I'll go off and try to implement something someone has mentioned and realize they left a big portion of information out or what's really going on is different because of version differences....anyway....

What I've got going on is a domain and a subdomain. My forums are located in the "forms.website.com" subdomain, and the rest of the site is under the "www.website.com" domain name. I've got everything setup to where session variables are shared across the entire domain including subdomains and I've tested this and it is working. Now what I'm needing to have happen is for the user to be redirected to their previous webpage after logging in. Say the login box is at www.website.com/page.php....i need for them to come back to that page after logging in instead of being taken to the board index.

I've tried several solutions all of which fail....does anyone know why this is, is there a bug somewhere? I mean I've even gone as far as hard coding a url into the redirect function on the ucp.php page and still nothing....frustrating....lol

User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 49772
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: redirect to subdomain on login?

Post by stevemaury » Mon Jun 25, 2012 9:57 pm

Obviously, you have some kind of custom login setup for your web page. Can you tell us more about it?
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. PM or email me.

All unsolicited PMs will be ignored.

dsm phreak
Registered User
Posts: 77
Joined: Fri Oct 15, 2010 3:15 am

Re: redirect to subdomain on login?

Post by dsm phreak » Mon Jun 25, 2012 11:21 pm

The login is basically the same as it is in the template files but instead of using the
{ variables_that_look_like_this }, the paths are hard coded....here is the code for the login box as it appears on the page:

Code: Select all


<div id="infoBox">			
			<div id="heading1">
				<h2>Support</h2>
			</div>
			<div style="margin-left: 10px; margin-right: 10px;">
			
			
			<div id="login">
			<form method="post" action="http://forums.site.com/ucp.php?mode=login">
				<table>
					<tr>
						<td id="lgnAlgn">Username</td>
						<td id="lgnAlgn">Password</td>
					</tr>
					<tr>
						<td id="lgnAlgn"><input class="post" type="text" name="username" size="" /></td>
						<td id="lgnAlgn"><input class="post" type="password" name="password" size="" /></td>
						<td id="lgnAlgn"><input type="submit" class="btnmain" name="login" value="Login"/></td>
					</tr>
					<!-- IF S_AUTOLOGIN_ENABLED -->
					<tr>
						<td id="lgnAlgn"><input type="checkbox" class="radio" name="autologin" /><label>Keep me logged in</label></td>
						<td id="lgnAlgn"><a href="../forums.racecore.com/ucp.php?mode=register">Register</a></td>
					</tr>
					<!-- ENDIF -->
				</table>
				{S_FORM_TOKEN}
			</form>	
		</div>

That is the code for login that is found in the main domain then when you look at the action="" tag you can tell it's going into the subdomain where all the phpbb files are hosted...this part works, it logs you in just fine, but always redirects you to index.php of forums.site.com????
Last edited by dsm phreak on Thu Jun 28, 2012 6:19 pm, edited 1 time in total.

dsm phreak
Registered User
Posts: 77
Joined: Fri Oct 15, 2010 3:15 am

Re: redirect to subdomain on login?

Post by dsm phreak » Tue Jun 26, 2012 5:07 pm

If anymore information is needed as to how I've got everything setup just let me know. I'd be more than happy to explain further if needed...

dsm phreak
Registered User
Posts: 77
Joined: Fri Oct 15, 2010 3:15 am

Re: redirect to subdomain on login?

Post by dsm phreak » Thu Jun 28, 2012 1:21 pm

Anyone? I read this thread http://www.phpbb.com/community/viewtopi ... &t=2015565 with high hopes but this fix doesn't seem to be working either....all I'm basically wanting to do is redirect to a subdomain once the user logs in...this shouldn't be that difficult of a task to accomplish :?:

I'm going to go dig through some of the files and see what I can come up with...there has to be something I'm missing somewhere...

dsm phreak
Registered User
Posts: 77
Joined: Fri Oct 15, 2010 3:15 am

Re: redirect to subdomain on login?

Post by dsm phreak » Thu Jun 28, 2012 2:50 pm

Alright I did some playing around and got the redirect to work for pages in the forums.site.com domain making all links relative to the root of that directory since that is where ucp.php is located. However when I try to redirect to a url, nothing happens it just goes straight to the index.php page. BUT whenever I enter the path to the folder of the site relative to forums.site.com/ucp.php I get a not found error and I can see in the url:

Code: Select all

http://forums.site.com/site.com/page.php?sid=2c3b6c0fb6af2252d23245dc55e659e9
The error reads:
Not Found

The requested URL /site.com/page.php was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
The value I'm giving to the redirect hidden field is:

Code: Select all

<input type="hidden" name="redirect" value="./../site.com/page.php">
I've also placed {S_LOGIN_REDIRECT} right before {S_HIDDEN_FIELDS} as mentioned to do in another thread...something i did notice though was that there was no {S_LOGIN_REDIRECT} field in my login_body.html file until I placed that one there...weird???

Any Ideas???

dsm phreak
Registered User
Posts: 77
Joined: Fri Oct 15, 2010 3:15 am

Re: redirect to subdomain on login?

Post by dsm phreak » Thu Jun 28, 2012 6:19 pm

Alright, so I've discovered that when you assign the hiddenfield value the url such as:

Code: Select all

<input type="hidden" name="redirect" value="http://www.site.com/page.php">
You receive no errors but it is as if the $redirect variable is ignored and the site is redirected to the default url, which is the index.php file of phpbb installation's root directory

So this sounds almost exactly like what was going on in this thread: http://www.phpbb.com/community/viewtopi ... &t=2015565

only I've tried this fix as mentioned above and nothing happened....but then there's the thought that {S_LOGIN_REDIRECT} was never included in my login_body.html template file...the template i'm using was based on subsilver2...don't know if this matters or not...????

dsm phreak
Registered User
Posts: 77
Joined: Fri Oct 15, 2010 3:15 am

Re: redirect to subdomain on login?

Post by dsm phreak » Thu Jun 28, 2012 9:07 pm

I've been buried in deep all day and it appears I have solved this delima my fellow "wackers of code"...After aquainting myself with how the entire redirect structure of phpbb works I discovered that one of the functions had a parameter that's sole purpose was to allow or dis-allow external redirects. Set the little guy to true and all appears to be well.

For anyone who might stumble across this, the function I am referring to is meta_refresh() http://wiki.phpbb.com/Meta_refresh

SOLVED!!!

Mavvv
Registered User
Posts: 1
Joined: Wed Jan 30, 2013 1:48 am

Re: redirect to subdomain on login?

Post by Mavvv » Mon Apr 08, 2013 10:38 pm

dsm phreak, thanks for the digging you've done. I can't believe how little to no support or response there is on this issue. Just googling on it kept giving me topics with this exact same question but with zero replies.

I was able to fix the problem on the forum side after reading this topic. So logging in from a certain topic will send you back to that topic after login. But our forum is on a subdomain and the frontpage is using a custom login similar to yours. It just will not redirect back to the frontpage after logging in from there. Supposedly because it's an external redirect because the forum is on a the subdomain.

I've tried setting both the functions meta_refresh() and redirect() to true so they'd accept those URLs, but it's still not working unfortunately. :(

I'm thinking it has to do with this part, but it's pretty much unreadable with horrible bad coded short-hand if then else stuff. Did you change anything else in functions.php perhaps to make it accept external URLs?

Line #3096 in functions.php

Code: Select all

		if ($result['status'] == LOGIN_SUCCESS)
		{
			$redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx");
			$message = ($l_success) ? $l_success : $user->lang['LOGIN_REDIRECT'];
			$l_redirect = ($admin) ? $user->lang['PROCEED_TO_ACP'] : (($redirect === "{$phpbb_root_path}index.$phpEx" || $redirect === "index.$phpEx") ? $user->lang['RETURN_INDEX'] : $user->lang['RETURN_PAGE']);
I've also just found this topic on the dev board, where they are basically still deciding if it's a interesting enough feature to have. *facepalm*

Locked

Return to “[3.0.x] MOD Writers Discussion”

Who is online

Users browsing this forum: No registered users and 8 guests