Jump to content

Recommended Posts

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,

Link to comment
https://forums.phpfreaks.com/topic/267161-dynamic-urls-for-seo-purposes/
Share on other sites

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").

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.