• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • Last Modified:

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.
0
majdolyan
Asked:
majdolyan
  • 2
  • 2
3 Solutions
 
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
 
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
 
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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now