<p>I see often (rewritten) URLs without ID in it, like on some wordpress installations. What is the best way of achieve this?</p>
<p>Example: site.com/product/some-product-name/</p>
<p>Maybe to keep an array of page names and IDs in cache, to avoid DB query on every page request?
How to avoid conflicts, and what are other issues on using urls without IDs?</p>

[{'answer_id': 13216, 'author': 'Keith', 'author_id': 905, 'author_profile': 'https://Stackoverflow.com/users/905', 'pm_score': 1, 'selected': False, 'text': "<p>As long as product names are unique it shouldn't be an issue. It won't take any longer (at least not significant) to look up a product by unique name than numeric ID as long as the column is indexed.</p>\n"}, {'answer_id': 13218, 'author': 'Brian Warshaw', 'author_id': 1344, 'author_profile': 'https://Stackoverflow.com/users/1344', 'pm_score': 3, 'selected': True, 'text': '<p>Using an ID presents the same conundrum, really--you\'re just checking for a different value in your database. The "some-product-name" part of your URL above is also something unique. Some people call them slugs (Wordpress, also permalinks). So instead of querying the database for a row that has the particular ID, you\'re querying the database for a row that has a particular slug. You don\'t need to know the ID to retrieve the record.</p>\n'}, {'answer_id': 13233, 'author': 'Brian Warshaw', 'author_id': 1344, 'author_profile': 'https://Stackoverflow.com/users/1344', 'pm_score': 1, 'selected': False, 'text': "<p>Wordpress has a field in the wp_posts table for the slug. When you create the post, it creates a slug from the post title (if that's how you have it configured), replacing spaces with dashes (or I think you can set it to underscores). It also takes out the apostrophes, commas, or whatnot. I believe it also limits the overall length of the slug, too.</p>\n\n<p>So, in short, it isn't dynamically decoding the URL into the post's title--there's a field in the table that matches the URL version of the post name directly.</p>\n"}, {'answer_id': 89901, 'author': 'Devin Reams', 'author_id': 16248, 'author_profile': 'https://Stackoverflow.com/users/16248', 'pm_score': 1, 'selected': False, 'text': '<p>As you may or may not know, the URLs are being re-written with Apache\'s <strong>mod_rewrite</strong> module. As mentioned here, Wordpress is, in the background, assigning a slug after sanitizing the title or post name.</p>\n\n<p>But, to answer your question, what you\'re describing is Wordpress\' "Pretty Permalinks" feature and you can learn more about it in the <a href="http://codex.wordpress.org/Using_Permalinks" rel="nofollow noreferrer">Wordpress codex</a>. Newer versions of Wordpress do the re-writing internally (no .htaccess editin, <a href="http://codex.wordpress.org/Function_Reference/WP_Rewrite" rel="nofollow noreferrer">wp_rewrite</a> instead). Which is why you\'ll see the same ruleset for any permalink structure.</p>\n\n<p>Though, if you do some digging you can find the old rewrite rules. For example:</p>\n\n<pre><code>RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ /index.php?year=$1&amp;monthnum=$2&amp;day=$3 [QSA,L]\n</code></pre>\n\n<p>Will take a URL like <code>/2008/01/01/</code> and direct it to <code>/index.php?year=2008&amp;monthnum=01&amp;day=01</code> (and load a date category).</p>\n\n<p>But, as mentioned, a page like <code>product-name</code> exists <strong>only</strong> because Wordpress already sanitized the post title and stored it as a field in the database.</p>\n'}]
['https://Stackoverflow.com/questions/13213', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1407/']