apache rewrite重写url隐藏index.php

现在很多项目

 http://www.test.dev/index.php/home/index

http://www.test.dev/index.php?s=/admin/login

等等

 

如何访问   http://www.test.dev/index.php/home/index 相当于自动访问 http://www.test.dev/home/index

省略中间的index.php呢?

1 在windows的php  apache环境中开启conf的httpd.conf 找到LoadModule rewrite_module modules/mod_rewrite.so的#号去掉

 

2 AllowOverride None 修改为 AllowOverride All

 

3 目录创建的.htaccess 增加以下内容

<IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php?$1 [L,QSA]
        #RewriteRule . index.php
        RewriteCond %{REQUEST_FILENAME} ^[A-Z]{3,}\s(.*)/index.php [NC]
</IfModule>
 

然后重启apache

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

明雨星云

感谢,我会继续创作更优质作品

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值