Home>Article>PHP Framework> How to set up pseudo-static removal directory in thinkphp

How to set up pseudo-static removal directory in thinkphp

藏色散人
藏色散人 Original
2022-12-05 09:35:50 1300browse

thinkphp设置伪静态去除目录的方法:1、在httpd.conf配置文件中加载mod_rewrite.so模块;2、将httpd.conf中Allowoverride None的None改为All;3、修改对应的项目配置文件;4、在项目的根目录下面建立一个.htaccess文件即可。

How to set up pseudo-static removal directory in thinkphp

本教程操作环境:Windows7系统、ThinkPHP5版、Dell G3电脑。

thinkphp怎么设置伪静态去除目录?

ThinkPHP实现伪静态如何去掉目录中的index.php

Myapp是我的项目文件名,默认的访问地址是上面这样的。为了使URL更加简介友好,现在要去掉中间的index.php,方法如下:

1。确认httpd.conf配置文件中加载了mod_rewrite.so 模块,加载的方法是去掉mod_rewrite.so前面的注释#号

2。将httpd.conf中的Allowoverride None 将None改为All

3。打开对应的项目配置文件,我的项目配置文件是Myapp/Conf/config.php ,在这个配置文件数组中增加一行,‘URL_MODEL’=>2

4。在项目的根目录下面建立一个.htaccess文件,里面写入下面的内容:

 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 

如果你的服务器支持rewrite,现在就可以通过http://localhost/Myapp/Index/index/访问Index模块下面的index操作。

推荐学习:《thinkPHP视频教程

The above is the detailed content of How to set up pseudo-static removal directory in thinkphp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn