Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8153535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:02:59+00:00 2026-06-06T16:02:59+00:00

I have a url like www.example.com/mypage.php?id=324 That number 324 is auto incremented (meaning that

  • 0

I have a url like www.example.com/mypage.php?id=324

That number 324 is auto incremented (meaning that person is 324th user of the website), and each user can set own user url, which is stored in mysql table (alphanumeric only).

Let’s say, user number 324 has user url ‘peter’

I am trying to replace mypage.php?id=324 to peter, so the url can be displayed like www.example.com/peter

But I still want to maintain mypage.php?id=324 internally, so if someone types www.example.com/mypage.php?id=324, it can be redirected to www.example.com/peter

I guess this is vanity url like facebook does?

I’ve searched all over the web, and even bought a book about htaccess, but I still couldn’t figure this out. Please help me! Thank you so much in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T16:03:01+00:00Added an answer on June 6, 2026 at 4:03 pm

    URL rewriting step by step…

    Step 1 – decide how you want client-side URLs to look

    You’ve done this part – you want example.com/peter to be what your user sees

    Step 2 – work out the server-side URLs

    Technically, you could produce a huge list of hard coded rewrite rules, e.g.

    RewriteRule ^peter$ mypage.php?id=324
    RewriteRule ^alice$ mypage.php?id=325
    RewriteRule ^bob$ mypage.php?id=326
    

    But that’s not particularly efficient when you have a lot of users.

    Your mypage.php will accept an id, but you’ll really need to modify it so that it can accept a possible username (but assume it will contain all sorts of garbage). Let’s say you decide to allow it to take another query string argument ‘hint’. So now you have to get a URL like this working: example.com/mypage.php?hint=peter

    Ensure your script produces a 404 response for any username it doesn’t understand.

    Step 3 – product rewrite rules to map client-side to server-side URLS

    One way to do this would be something like this – the first RewriteCond line ensures the rule only fires if the request doesn’t match an actual file. The RewriteRule will cause the request to be handled by mypage.php, but passing in the rest of the URL as the ‘hint’ paramter. The ‘qsa’ part is short for ‘query string append’, which means any query string present in the original URL is added to the written rule. The ‘l’ means ‘last’, so that no further rules are invoked to handle this request.

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([a-z]+)$ mypage.php?hint=$1 [qsa, l]
    

    In mypage.php you’d then look up the user using the hint.

    Note I’ve been pretty restrictive in the pattern, only sequences of lower case letters allowed. This will help ensure your script isn’t invoked for every 404 your site might produce .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a url like this - www.example.com/blog.php/username, it will take you to the
I have a string that looks like string url = "www.example.com/aaa/bbb.jpg"; "www.example.com/" is 18
I have an url like this: http://www.w3schools.com/PHP/func_string_str_split.asp I want to split that url to
I have url that looks like this... http://www.example.com/accounts/?token=111978178853984|683b8096732be7fd725d3332-557626087|m9lSbmoYhZ6Yut4OC3smY1fRf1E. from the token 111978178853984|683b8096732be7fd725d3332- 557625434 |m9lSbmoYhZ6Yut4OC3smY1fRf1E
I want that every user has a profile-url like this: www.example.com/username But my php
I have an URL like this http://www.example.com/Data/image/office-dôn-sì-à.jpg I want to copy that file to
I have a peculiar situation, my website is like www.example.com/page.php?url=homepage . I am trying
If I have a URL like: http://www.example.com:9090/test.html Then I know that www.example.com is the
I have a URL that is like: www.example.com/task1/1.3.html#a_1 How can I get the a_1
I have URL scheme for my blog like this: http://www.example.com/%YEAR%/%MONTH%/%CATEGORY%/%POST_TITLE%/ Now i want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.