As many of you know when someone creates a StackOverflow question a new page is generated and it is visible in the various search engines as well. I was wondering how PHP code created these pages. It turns out that most websites like this have one page, something like profile.php and it loads the data from a MySQL database. My question is as follows: If there is only one physical file how can the URL change and how does google list all of the pages/profiles/question from sites like StackOverflow or Facebook if there is only one actual page?
5条回答 默认 最新
- dongrang2140 2016-09-12 19:27关注
You tell search engines 'Google, Bing, ..etc' for example to see your website by giving them
sitemap.xml
listing your pages, allow their web-bots (spider) access too the site and crawl the data and links, you may have one page likeposts.php
and it is different with parametersposts.php?id=123
orposts.php?name=mypost
Edited: If you want use one file
posts.php
and make sitehttp://domain.com/posts/posttitle
you need to apply Front Controller Pattern site point link and this implies setting you server Apache/Nginx to redirect the requests to one file (URL rewrite) and this file contain the logic for handle the request or use MVC framework解决 无用评论 打赏 举报