-1

Websites like reddit, youtube, quora and even stackoverflow create a new page for every new question/post/video that users submit/upload. How do they do that? I'm expecting they use php and MySQL. Could somebody roughly tell me how it's done?

An example would be this question that I now asked.

stackoverflow.com/questions/51026958/how-do-certain-websites-create-new-pages-when-you-submit-a-post-video

Shortly: How do i create an unique url for every post with php and mysql on my website?

drstuggels
  • 122
  • 2
  • 12
  • 3
    The magic is behind the data which is stored in the db and the front-end templates that are used to show the data – B001ᛦ Jun 25 '18 at 15:25
  • 2
    *"I'm expecting they use php and MySQL."* could be ... or one of dozens of other server-side language + database combinations. – CD001 Jun 25 '18 at 15:27
  • 3
    Those are not necessarily new pages, just new URL's which are just a link they provide pointing to a resource. The page is generated on the fly for your content stored in a datastore and a response is generated on that URL, no 'page' needs be created, per se. – Brandon Culley Jun 25 '18 at 15:28
  • They use a technic called `URL rewriting` or `SEO url` in a .htaccess file or application code to add to @BrandonSørenCulley 's comment – Raymond Nijland Jun 25 '18 at 15:34
  • @RaymondNijland More generically it's having a "routing layer" between the URI and the code and/or content that's linked to it. – tadman Jun 25 '18 at 15:35
  • Do you know any tutorials about url rewriting? – drstuggels Jun 25 '18 at 15:37
  • "More generically it's having a "routing layer" between the URI and the code and/or content that's linked to it." true @tadman i know that i maked it more searchable on Google for the topicstarter by giving him some terms.. – Raymond Nijland Jun 25 '18 at 15:37
  • "Do you know any tutorials about url rewriting? " https://stackoverflow.com/questions/16388959/url-rewriting-with-php very basic example – Raymond Nijland Jun 25 '18 at 15:39

1 Answers1

0

Frameworks like Fat-Free Framework and Laravel, among others, and they handle this by introducing an abstraction between the URL and the content.

That is, the URL no longer represents a particular asset or script on your filesystem, but a more abstract concept of a resource.

Legacy PHP applications have paths that look like:

/users/info.php?id=2

A modern application will describe this differently:

/users/2/info

Where that path has data encoded in it that can be extracted and utilized by your MVC layer.

You can see how this works in practice by using Laravel as an example.

It's worth noting that these routed URLs are a lot cleaner, there's less technical cruft in them, and the back-end you're using can change completely without having to fake it or break links.

tadman
  • 208,517
  • 23
  • 234
  • 262