如何根据用户请求使用php创建子页面?

如何根据用户请求使用php创建子页面?,php,url,subdirectory,Php,Url,Subdirectory,如果我的网站url类似于someUrl.com,并且注册用户希望向我的网站添加文章,我希望使用php创建一个子页面: 比如someUrl.com/someSubPage 所以我的问题是:我应该使用php在服务器上创建一个新文件,还是应该将文章中的数据保存在数据库中,并在每次用户请求时生成该文件?如果我选择第二个选项,那么url(someUrl.com/someSubPage)呢?是否仍可能有此的url 提前谢谢你!:D 编辑: Ok数据库似乎是更好的方法。但是搜索引擎呢?没有框架我能做到吗?是的

如果我的网站url类似于someUrl.com,并且注册用户希望向我的网站添加文章,我希望使用php创建一个子页面:

比如someUrl.com/someSubPage

所以我的问题是:我应该使用php在服务器上创建一个新文件,还是应该将文章中的数据保存在数据库中,并在每次用户请求时生成该文件?如果我选择第二个选项,那么url(someUrl.com/someSubPage)呢?是否仍可能有此的url

提前谢谢你!:D

编辑:
Ok数据库似乎是更好的方法。但是搜索引擎呢?没有框架我能做到吗?

是的,没有框架你也能做到。但是你可以考虑CODEDENITER,因为它很容易安装和学习,没有很大的重量。如果不使用:则必须创建一个包含以下内容的.htaccess文件:

RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]


# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to 
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size 
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

如果在文件系统中找不到该文件,将加载page index.php。您可以使用$\u SERVER['REQUEST\u URI']获取请求的页面。

简而言之:数据库-绝对;url-没问题,现在它们很少代表实际的目录结构;如何-更好地查看框架(如Laravel)谢谢!:像谷歌这样的搜索引擎能找到这些页面吗?没有框架也可以吗?好的,谢谢!我真的应该学习一点关于htaccess文件的知识,因为我一点也不懂(请参阅注释)。但多亏了你,我现在知道这是可能的。