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 4578810
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:33:17+00:00 2026-05-21T20:33:17+00:00

Is it an ok practice to have a URL column in my database that

  • 0

Is it an ok practice to have a URL column in my database that would store a URL such as: /this-is-a-keyword

And then use that column in my php query to get the information I need instead of using an integer column?

So basically when I went to Mysite.com/this-is-a-keyword I would return the result from that row.

  • 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-21T20:33:18+00:00Added an answer on May 21, 2026 at 8:33 pm

    More or less, what you are describing is called a slug and it’s normally constructed by passing the most descriptive string (usually the title of the page / post) to a slugify function, like this one:

    function Slug($string)
    {
        return strtolower(trim(preg_replace('~[^0-9a-z]+~i', '-', html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8')), ENT_QUOTES, 'UTF-8')), '-'));
    }
    

    The problem with this, however, is that the result may not be unique, consider the following:

    echo Slug('Alix Axel');          // alix-axel
    echo Slug('Álix Ãxel');          // alix-axel
    echo Slug('@Álix----_Ãxel!?!?'); // alix-axel
    

    All return the same output even though the input differs. One of my favorite (and also most widespread) approaches is to do like StackOverflow does it (using the ID and slug in combination):

    stackoverflow.com/questions/5845732/clean-urls-and-database

    If you want to avoid this, you need to make sure the slug you are generating does not exist already in the database, if it does append an incremented number until it satisfies the unique condition.

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

Sidebar

Related Questions

Imagine that I have a Spring MVC controller something like this: @Controller @RequestMapping(/base-url) public
Is it considered bad practice to have multiple views for same URL in MVC,
I have a practice exam for my compilers course with the following questions that
First off, I'm aware this is a bad practice and I have answered many
I have a best practice question. I'm developing a OO MVC framework in PHP,
I have a web application that uses RESTful url patterns. Currently if a users
I have an ajax call as below: $.ajax({ type: GET, url: process.php, data: dataString,
I have this page table structure to store all the website page information, page_id
I have a handler (c#/asp.net) that pulls images from a database. The current format
I have a URL http://myapp.com/get_data that returns an application/json Content-Type . When I browse

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.