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 7413879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:58:14+00:00 2026-05-29T06:58:14+00:00

I am creating a website with a referral scheme, where the referral URL will

  • 0

I am creating a website with a referral scheme, where the referral URL will be something like http://example.com/123456

I would like to display the URL as simply http://example.com/ but still capture the 123456 and give the referral point.

Would it be possible to do this with .htaccess mod_rewrite? something like

RewriteRule ^([0-9]+) ?ref=$1 [L]

would work to forward the URL, but is there a way to redirect here and display http://example.com/ in the address bar, without the referrer code?

It would obviously be possible with PHP Headers but I’d prefer not to use this if at all possible.

  • 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-29T06:58:15+00:00Added an answer on May 29, 2026 at 6:58 am

    This is not possible in a simple way with RewriteModule only, because of HTTP being a stateless protocol. If you remove the referral ID and redirect the user, then you won’t know the ID anymore on the second request.

    So you have to save the ID in a cookie or session with PHP, and redirect the user with the Location header afterwards.

    htaccess

    RewriteRule ^([0-9]+) index.php?ref=$1 [L]
    

    index.php

    if (isset($_GET["ref"])) {
      setcookie("refid", $_GET["ref"]);
      header("Location: http://example.com/");
      exit;
    }
    if (isset($_COOKIE["refid"])) {
      echo "You came from ref id: $_COOKIE[refid]";
    } else {
      echo "You came without a ref id.";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating my website in asp.net 4 and would like to know if
I'm creating a website for my church and I'm having problems making it display
I have been creating a website with Ruby on Rails, and will be hosting
I'm creating a website that will be in English, Chinese and Korean. There are
I'm creating a website that will have the admin upload documents available only to
I am creating a website, where I will sell computer and calculator programs. When
I'm creating a website which will require much AJAX functionality. At the moment I'm
I am working on creating website with Yii framework and I have a problem
When creating a website using Asp.Net and using controls such as the ListView is
so I'm creating karaoke website for client, and I need to secure videos from

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.