computermax2328 Posted August 16, 2012 Share Posted August 16, 2012 Hello Again, My last post for the night, I swear. I am building a blog and I have blog home page where a while loop outputs previews of all my blog posts. At the bottom of each preview is a "read more" link. Simply, enough I could just create a file called article.php and pass an id with the link to this page and have the id populate the page. Then it dawned upon me, is there a way to use php to create a unique URL for every page for SEO purposes. For example, if I write an article about myself, Max Baldwin, and I want everyone who Googles my name to find this article, Google would find my article if the URL was www.example.com/max-baldwin. How do I get this dynamic URL with the information I already have in my database? Pretty much every article would have unique URL. Does this make sense? Thanks in advance, Quote Link to comment https://forums.phpfreaks.com/topic/267161-dynamic-urls-for-seo-purposes/ Share on other sites More sharing options...
requinix Posted August 16, 2012 Share Posted August 16, 2012 It's called "URL rewriting" and there is a lot written about it on the Interwebs. The key concept is that you aren't actually creating pages or any real files or directories but telling the web server that URLs following a pattern should be treated like something else. For instance, you could tell Apache that anything /whatever (that doesn't correspond to an actual file) should actually go to /article.php?id=whatever instead. But keep in mind that you can't just automagically add something to the new URL: all you have to work with is what the original one provided. That means you can't go from /max-baldwin to /article.php?id=5 because there's no "5" in the first URL (just the "max-baldwin"). Quote Link to comment https://forums.phpfreaks.com/topic/267161-dynamic-urls-for-seo-purposes/#findComment-1369816 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.