没有mod_rewrite的在PHP清洁网址 [英] Clean URLs in PHP without mod_rewrite

查看:111
本文介绍了没有mod_rewrite的在PHP清洁网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个后端的一个网站,我建了PHP中的客户端(我很少使用),这是基本完成。我是个Rails开发为主,所以我有一个困难时期不会为​​CRUD设置一些bastardized版本,我试图清理网址。

I am developing a backend for a site I built for a client in PHP (which I rarely use), which is almost completed. I'm a Rails developer primarily, so I'm having a hard time not going for some bastardized version of a CRUD setup, and I am attempting to clean up the urls.

我想我的网址是像这样:

I would like my urls to be like so:

http://www.example.com/videos/name-of-video /

我计划只是把URL的最后一点 $ _ SERVER ['PHP_SELF'] 并使用通过数据库搜索,但我想这样做是扔的index.php文件中的 http://www.example.com/videos/ 目录并且有它被用来当我明确地指出别人 http://www.example.com /视频/ / ,名称视频,如果是有道理的。

I plan on just taking the last bit of the url from $_SERVER['PHP_SELF'] and searching through the DB using that, but what I would like to do is throw the index.php file in the http://www.example.com/videos/ directory and have it be used when I explicitly point someone to http://www.example.com/videos/name-of-video/, if that makes sense.

将这项工作作为是,如果我把index.php文件中/视频/目录下,或者是别的什么必要?是否有可能做不搞乱周围的htaccess的?

Will this work as is, if I put the index.php in the /videos/ directory, or is something else needed? Is it possible to do without messing around with htaccess?

对不起,我的可怜的解释。我希望这是有道理的。

Sorry for my pathetic explanation. I hope it makes sense.

谢谢!

推荐答案

根据我所知,这操作是不可能不接触的.htaccess。 当你写的网址 http://www.example.com/videos/name-of - 视频/ 你的服务器是肯定会寻找在名称视频的文件夹,文件夹中的index.php文件。不存在

As per my knowledge this manipulation is not possible without touching .htaccess. when you write the url http://www.example.com/videos/name-of-video/ your server is definitely going to look for the index.php file in the folder name-of-video folder. which does not exist.

如果能取得这样的任务,而无需的.htaccess那么他们就从未使用过的。 并通过你为什么不希望使用.htaccess中的方式??

If this task could have been achieved without .htaccess then they would have never been used. And by the way why don't you want to use .htaccess..??

这篇关于没有mod_rewrite的在PHP清洁网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆