zoukankan      html  css  js  c++  java
  • thibkphp5 改好.htaccess 后依旧 模块不存在 的解决方法!

    https://blog.csdn.net/wanganji5252/article/details/81293082

    隐藏入口index.php的整了好久 主要是phpstudy的.htaccess跟thinkphp5文档的写法不一样所导致的 

    所以记录下来引以为戒。

    以Apache为例,需要在入口文件的同级(public目录下)添加.htaccess文件(官方默认自带了该文件),内容如下:


     
    <IfModule mod_rewrite.c>
    Options +FollowSymlinks -Multiviews
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
    </IfModule>


    如果用的phpstudy,规则如下:

     
    <IfModule mod_rewrite.c>

    Options +FollowSymlinks -Multiviews

    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]

    </IfModule>
    接下来就可以使用下面的URL地址访问了


     
    http://tp5.com/index/index/index

    http://tp5.com/index/index/hello

    如果你使用的apache版本使用上面的方式无法正常隐藏index.php,可以尝试使用下面的方式配置.htaccess文件:


     
    <IfModule mod_rewrite.c>

    Options +FollowSymlinks -Multiviews

    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
    </IfModule>
    如果是Nginx环境的话,可以在Nginx.conf中添加:


     
    location / { // …..省略部分代码

    if (!-e $request_filename) {

    rewrite ^(.*)$ /index.php?s=/$1 last;

    break;

    }

    }
     
    ————————————————
    版权声明:本文为CSDN博主「腐腐gay」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/wanganji5252/article/details/81293082

  • 相关阅读:
    js 兼容nextSibling
    ie background repeat 出现空白
    自制日历组件
    js cookie操作方法
    html table 上下左右边框
    js window.onload函数
    js 兼容event.target
    ie minheight
    css table 固定宽度
    [翻译]建立你的第一个Visual WebGui应用程序
  • 原文地址:https://www.cnblogs.com/Alan2016/p/11848453.html
Copyright © 2011-2022 走看看