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.
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
index.php