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

  • SEARCH
  • Home
  • 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 4572928
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:42:53+00:00 2026-05-21T19:42:53+00:00

What is the best way to create user vanity URLs under a LAMP configuration?

  • 0

What is the best way to create user vanity URLs under a LAMP configuration?

For example, a user profile page could be accessed as follows:

http://www.website.com/profile.php?id=1

Now, if a user enters a “vanity URL” for their profile I would want the the vanity URL to load the page above.

For example, if a user selects “i.am.a.user” as their vanity URL and their user id in the database is 1 then http://www.website.com/profile.php?id=1 would be accessible by that URL and http://www.website.com/i.am.a.user .

I’m aware of mod rewrites in .htaccess but not sure how that would work here.

As I mentioned my site is in PHP, MySQL, Linux and Apache.

Thanks.

  • 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-05-21T19:42:54+00:00Added an answer on May 21, 2026 at 7:42 pm

    Say your other pages had specific URLs that you could check against, the following should help.

    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-zA-Z0-9-_]*)$ /profile.php?user=$1 [L]
    

    This helps to maintain current URLs, while allowing for the user shortcut URLs. Also, the RewriteRule will only match URLs that don’t contain a /, which will help protect against non-intended redirects. So,

    /i-am-a-user -> MATCHES
    /i_am_a_user -> MATCHES
    /i-!am-a-user -> NOT MATCHED
    /i.am.a.user  -> NOT MATCHED
    /i.am.a.user/ -> NOT MATCHED
    /some/page/ -> NOT MATCHED
    /doesnotexist.php -> NOT MATCHED
    /doesnotexist.html -> NOT MATCHED
    

    Hope that helps.

    EDIT

    I’ve updated the rules above so that actual files/directories aren’t redirected as well as making sure that any .php or .html file is not sent to profile.php either.

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

Sidebar

Related Questions

What's the best way to create a file under a nested folder in Sharepoint
What is the best way to create a data bound ASP.NET user control? I
Currently, I have URLs that look like this: http://www.example.com/user/create http://www.example.com/user/edit/1 But now, I have
How is the best way I can create a jailed user on a Linux
What would be the best way to create a dynamic array for a user
What is best way to create a blinking image animation in wp7? Is there
What is the best way to create databases on C# application, I mean by
What is the best way to create multi-language database? To create localized table for
What is the best way to create a unique id column for table records
What is the best way to create a 'global event' in flex/actionscript - preferably

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.