HighDots Forums  

Problems with login script after implementing URLrewrite

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Problems with login script after implementing URLrewrite in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AngryCloud
 
Posts: n/a

Default Problems with login script after implementing URLrewrite - 08-25-2008 , 07:36 PM






My entire site is based off a single index page, in which there is always a
'log in' area to the left if no user is currently logged in.

For my user pages, I use a PHP script to rewrite the URL from
'mydomain.com/index.php?page=user&id=123' to 'mydomain.com/username'.

After implementing the rewrite script, I can no longer log in while on a user
page. It seems to process the login script just fine, considering it redirects
back to the right page, but for some reason the session variables are not set.

Any help with this would be much appreciated, and I would be happy to provide
any more details if necessary. Thanks in advance.


Reply With Quote
  #2  
Old   
Michael Fesser
 
Posts: n/a

Default Re: Problems with login script after implementing URL rewrite - 08-25-2008 , 09:13 PM






..oO(AngryCloud)

Quote:
My entire site is based off a single index page, in which there is always a
'log in' area to the left if no user is currently logged in.

For my user pages, I use a PHP script to rewrite the URL from
'mydomain.com/index.php?page=user&id=123' to 'mydomain.com/username'.

After implementing the rewrite script, I can no longer log in while on a user
page. It seems to process the login script just fine, considering it redirects
back to the right page, but for some reason the session variables are not set.
Are you using URL-based sessions instead of cookies? If yes, you have to
manually append the session ID to it if you perform any redirects or
things like that. But that's just guessing, since you didn't post any
code. How's that "rewriting" done?

Micha


Reply With Quote
  #3  
Old   
AngryCloud
 
Posts: n/a

Default Re: Problems with login script after implementing URLrewrite - 08-26-2008 , 12:34 AM



My index page checks if there is a cookie to set the variable
$_SESSION['user_id'] automatically so people don't have to log in every time
they come back to the site.

The rewriting script is integrated into the index page before the login script.
Basically it checks if ($_GET['page'] == 'user'). If true, it runs this line:
header('location: '.$row_user['username']);

Then the script sets a variable to $_SERVER['REQUEST_URI'], minus the slash,
and checks if the variable is a valid username. If so, it sets $_GET['page'] to
'user' and $_GET['id'] to the user id.

By manually setting the $_GET variables, the page will be processed just as if
the URL had not been changed.


Reply With Quote
  #4  
Old   
AngryCloud
 
Posts: n/a

Default Re: Problems with login script after implementing URLrewrite - 08-26-2008 , 05:53 AM



I was wrong in my original post. The login script is not processed.

I think I have figured out what is happening. The reason visitors are
redirected to index.php when they try open a URL like 'mydomain.com/username'
is because I have this line in my htaccess file:

ErrorDocument 404 /index.php

Since the login form's target page is blank (the same page) it calls the
rewritten URL which triggers an error document since the path is not an actual
file or directory. This causes an extra redirect which erases the POST data.

I'm pretty sure I'm doing it wrong with the htaccess file though. Can you help
me change this to make it all work?


Reply With Quote
  #5  
Old   
AngryCloud
 
Posts: n/a

Default Re: Problems with login script after implementing URLrewrite - 08-26-2008 , 04:27 PM



I finally fixed the problem using rewrite in htaccess instead of the 404.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.