`
txf2004
  • 浏览: 6879550 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

是否需要使用mod_rewrite - 马永占 译

阅读更多

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。http://blog.csdn.net/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.


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics