thinkphp 3.2 nginx配置伪静态PUBLIC目录变成控制器如图,求高手指点

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了thinkphp 3.2 nginx配置伪静态PUBLIC目录变成控制器如图,求高手指点相关的知识,希望对你有一定的参考价值。

如何解决把控制器目录去除 ?

参考技术A Thinkphp中默认的URL地址是形如这样的:http://localhost/Myapp/index.php/Index/index/
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文件,里面写入下面的内容:
<IfModule rewrite_module>
RewriteEngine on
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
如果你的服务器支持rewrite,现在就可以通过http://localhost/Myapp/Index/index/访问Index模块下面的index操作。

thinkphp 伪静态 自定义后缀

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        
<rewrite>
 <rules>
<rule name="已导入的规则 1" stopProcessing="true">
 <match url="^(.*).shtml$" />
 <conditions logicalGrouping="MatchAll">
 <add input="{HTTP_HOST}" pattern="^(.*)$" />
 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
 </conditions>
 <action type="Rewrite" url="index.php/{R:1}" />
 </rule>
 </rules>
 </rewrite>
    </system.webServer>
</configuration>

 

以上是关于thinkphp 3.2 nginx配置伪静态PUBLIC目录变成控制器如图,求高手指点的主要内容,如果未能解决你的问题,请参考以下文章

如何配置thinkphp的伪静态重写

ThinkPHP怎么实现伪静态

ThinkPHP怎么实现伪静态

thinkphp部署服务器后出现404错误

Nginx 下Thinkphp5伪静态

Nginx下伪静态规则