Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 924693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:23:55+00:00 2026-05-15T19:23:55+00:00

When I want to redirect a user to a specific page behind a login

  • 0

When I want to redirect a user to a specific page behind a login wall and they’re not already logged in, they get redirected to the homepage where they can login. When they login, they are redirected to a default address.

How do I go about remembering where the users original destination, before they were redirected to the login page?

EDITED WITH SOLUTION

Thanks for the responses. What I’ve done is set a GET request when the user is detected to not have logged in, using the URL: domain.com/?url=$_SERVER[“REQUEST_URI”]

So when the user is redirected to the login page, the address that the user tried to get to is set in the GET value. When the user logs in and authenticates, I do a test to see if there’s a GET value, if there is, then append it to the end of the URL address bar.

END EDIT

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:23:56+00:00Added an answer on May 15, 2026 at 7:23 pm

    The easiest way is to add the URL of the current page to the login page as an argument:

    ... not logged in ....
     header("Location: loginpage.php?url=".
             urlencode($_SERVER["REQUEST_URI"]));
    

    (Note, for this, both scripts need to be on the same domain. If they are on different domains, you’d need to use something like "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"])

    and after login, redirecting to that page:

     header("Location: ".$_GET["url"]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to redirect users to an error page if they enter any URL
I want to redirect one specific url like: www.example.com/test/ex.gif to static.example.com/ex.gif How can i
i want to redirect peaple who goes in my site to other page if
I want to redirect to error page if the requested URI comes up with
Ive setup the following rule in Drupal: NOT condition - Logged in user has
How can i redirect my class on a specific page? I've implemented counting the
I want to redirect users when they log in to my site to a
Is there any way to redirect a page to a specific hash but prevent
I am trying to find a way to redirect a user when they come
Is there a way to redirect the user to an error page (view) when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.