mod_rewrite,php和.htaccess文件

mod_rewrite,php和.htaccess文件,第1张

mod_rewrite,php和.htaccess文件

一种方法是将所有内容重写为处理脚本

RewriteEngine onRewritebase /# only rewrite if the requested file doesn't existRewriteCond %{REQUEST_FILENAME} !-s# pass the rest of the request into index.php to handle     RewriteRule ^(.*)$ /index.php/ [L]

因此,如果您有请求http:// yourserver / foo / bar /

您实际上得到的是对http://yourserver/index.php/foo/bar的请求-
您可以离开index.php来决定如何处理/ foo / bar(使用$ _SERVER [‘PATH_INFO’]-
tom)

您只需要在第一次修改.htaccess。以后所有对不存在文件的请求都可以用PHP处理。

您可能还会发现mod_rewrite的文档很有用-
但保持简单或准备浪费大量的睡眠和头发来查找晦涩的错误。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5018526.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-14
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存