RewriteRule  for .htaccess File

Posted on 2009-02-10
Last Modified: 2012-05-06

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

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.
Question by:majdolyan
    LVL 43

    Assisted Solution


    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^([0-9]+)\
    RewriteRule .*[L,R=301,QSA]
    LVL 27

    Accepted Solution

    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


    Author Comment

    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.
    LVL 27

    Assisted Solution


    Author Closing Comment

    Thanks for your help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
    It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now