[原创]用Apache的mod_rewrite模块隐藏.PHP扩展名

fzjw fzjw 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
<VirtualHost *:80>
ServerAdmin webmaster@test.com
ServerName www.test.com
DocumentRoot /wwwroot/test/
DirectoryIndex index.php index.html
RewriteEngine on
#将所有*.php的文件扩展名去掉,剩下*.
RewriteRule ^(.*)\.$ $1\.php
</VirtualHost>

http://www.test.com/index.php?id=1
重写为
http://www.test.com/index.?id=1

如果
RewriteRule ^(.*)$ $1\.php
则可以通过http://www.test.com/index来访问index.php
我在Apache 1.3.33下测试,发现所有的CSS样式均不能显示,加上\.一切正常。
...全文

相关推荐

评论 22
收藏 已收藏
分享
返回顶部
fzjw
基础编程 21,889 成员 140,329 内容