RewriteRule for .htaccess File

Hi,

I want to add a RewriteRule to the .htaccess file to redirect the following URL Address for example

999.example.com
to
http://www.example.com/index.php?page=list&uid=999

The number 999 should be a variable and it could any be any number.

The idea is to have a short name that will leads to members profiles web pages.
majdolyanAsked:
Who is Participating?
 
caterham_wwwCommented:
A prerequisite is a wildcard dns entry pointing to your site
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([0-9]+)\.example\.com
RewriteRule ^$ /index.php?page=list&uid=%1 [L]

Open in new window

0
 
ravenplCommented:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^([0-9]+)\.example.com
RewriteRule .* http://www.example.com/index.php?page=list&uid=%1[L,R=301,QSA]
0
 
majdolyanAuthor Commented:
Thanks guys for your quick respond, however both didn't work.

What do you mean by "A prerequisite is a wildcard dns entry pointing to your site"? How can I have that on? or check if I have it? I have a cpanel and VPS hosting plan.
0
 
caterham_wwwCommented:
0
 
majdolyanAuthor Commented:
Thanks for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.