从自定义网址获取信息 [英] Get information from custom url
问题描述
我正在为一个学校项目的网站工作,但我遇到了一个小问题。我想用我的网址存储信息。我正在使用HTML5 + PHP + JavaScript。通常我会这样做: http://www.example.com/index.php ?files = share ,但我希望它是这样的: http://www.example .COM /文件/股。我不知道是否可以使用我使用的任何语言,但如果有其他语言的方式,我很高兴知道!
I'm working on a website for a school project, but i've run into a little problem. I want to use my url to "store information". I'm using HTML5 + PHP + JavaScript. Normally i would do it like this: http://www.example.com/index.php?files=share, but i want it to be like this: http://www.example.com/files/share. I don't know if it is possible with any of the languages i use, but if there is a way with an other language, i'm happy to know!
MB
推荐答案
使用您正在使用的技术执行此操作的最简单明了的方法是使用.htaccess和mod_rewrite格式化你的网址并让它们漂亮:
The most plain and simple way to do it with the technologies you are using is to use .htaccess and mod_rewrite to format your urls and make them "pretty":
http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/
然而,有许多框架具有路由设置,使其更加自动化,但它们有自己的学习曲线。我不确定是否因为这是一个被认为是作弊的学校项目,但如果这不是问题,你可以检查一个php框架,如laravel,codeignitor,yii等等。
However there are a number of frameworks with routing setups that make it a little more automatic, but they have their own learning curve. I am not sure if since this is a school project that would be considered cheating, however if that is not an issue you could checkout a php framework like laravel, codeignitor, yii etc etc etc.
为了学习,尝试使用.htaccess解决方案可能会很好。
It would probably be good, for the sake of learning, to experiment with the .htaccess solution.
这篇关于从自定义网址获取信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!