Emre Kozan
Emre Kozan

Reputation: 11

page redirect with .htaccess [custom URLs]

I want to make a referral system, but it's based on a referral system to find the value it had in the database, and I want to redirect the user's page with this code. I tried to explain the structure of the link should be at the bottom. How do we do this?

DATABASE --> USERCODE(A6465S) --> example.com/A6465S(USERCODE) --> USER PAGE(REDIRECT) --> site.com/users.php?id=10 --> COMPLETED

Upvotes: 0

Views: 109

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

Try this in your root/htaccess file :

#turn on the engine for rewriting
RewriteEngine On

#if the request  is for a existing file or directory, then skip the rewrite rule
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

#Rewrite the short url
RewriteRule ^([a-zA-Z0-9]+)/?$ /users.php?id=$1 [QSA,L]

Upvotes: 1

Related Questions