版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。http://blog.youkuaiyun.com/mayongzhan - 马永占,myz,mayongzhan
原文地址:http://www.phpguru.org/#212
最近php-general mailinglist 正在讨论关于mod_rewrite。我的观点很简单,不需要,请看下文:
/rental/property/23425
你可能认为上面的那个地址是rewrite的结果。你错了。是在.htaccess中使用了如下内容:
<Files rental>
ForceType application/x-httpd-php
</Files>
文件被apache当作PHP脚本来执行。意思是你可以使用REQUEST_URI这个服务器变量来得到提交的URL,然后显示内容。
Recent discussion on the php-general mailing list regarding mod_rewrite. My opinion is that if your needs are simple - it's not necessary. Consider:
/rental/property/23425
You may think that mod_rewrite is necessary here. It's not. Simply place this in a .htaccess file:
<Files rental>
ForceType application/x-httpd-php
</Files>
Now the file "rental" will be parsed by Apache as a PHP script. This means you can use the REQUEST_URI server variable to get the requested URI and show the appropriate content.
This is exactly how the "static" directory is done on this site. It's actually not a directory at all, but a PHP file that looks at the URL and determines the correct content to show.
本文介绍了一种不依赖mod_rewrite的URL映射方法,通过在.htaccess文件中配置特定指令,使得请求直接由PHP脚本处理,从而实现静态页面效果。

被折叠的 条评论
为什么被折叠?



