在使用PHP框架CI时,有个很恶心的地方就是他的URL需要带上index.php,比如我要建一个user模块,想要实现www.xxx.com/user/的效果,但是在CI框架下必须要www.xxx.com/index.php/user这样才能打开。
翻了下官方文档以及百度谷歌了下相关查询,网上的资料大多都不能用,全是虚假或过时了的信息,什么修改config,设置index_page为空,根本没用。经过丁老师的深入研究,发现了解决办法,什么都不用改,只需要3个步骤即可实现:
1.配置网站的nginx rule(宝塔直接在网站属性中设置):
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
2.在controller目录下增加php文件,User.php,代码如下:
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class User extends CI_Controller{
public function index(){
echo "user_Index";
exit;
}
}
3.打开config目录下的route.php文件,最底部添加两行:
$route['user']='user/index';
$route['user/(:any)']='user/$1';
大功告成!哪有那么复杂!有在使用CI框架中遇到难题的,尽管+v问我!
有同学提问,使用PHP在处理textarea提交的内容时,里边内容是换行了的,怎么把这些内容给解析为ul li格式呢?如:<ul<li aaa</li<li bbb </li</ul 其实很简单,使用...
int main() { auto hello= struct { int test() { return 1; } }().test(); }有初学C++的小伙伴提问,在运行C++代码时报错,错误提示如下:<source :2:...
js#replace替换 var str="Hello world! world is beautiful."; var str_new=str.replace("world","Jav...
没那么多废话,直接上修改方法public\assets\js\require-table.jspageSize: Config.pagesize || localStorage.getItem("pagesize")...
videojs是一款非常不错的html video播放器插件,很多同学经常在群里问我,说丁老师这个videojs怎么设置为宽度或者高度自适应呢,不想把video的width和height写死,有没有什么办法呢。丁老师经过研究发现啊,vide...
在使用python3.12时突然遇到提示windows No module named distutils,研究了一下,把解决办法分享出来。1.安装 setuptools,它现在也提供 distutils;2.从第三方源(如系统软件包)载入...
fastadmin里自定义按钮的btn-dialog,弹出窗口时默认大小,设置了data-area无效,经过研究后,发现了可用的方法,直接上代码不废话:table.on('post-body.bs.table',functi...
在日常开发过程中,突然发现svn无法提交和更新,出现“no path or pathfile specified on the command line”的错误,网上搜了一圈百度 google 以及stack overflow都没找到真正能...