首页 > 后端开发 > php教程 > thinkphp 隐藏index.php iis apache nginx

thinkphp 隐藏index.php iis apache nginx

不言
发布: 2023-03-23 21:56:02
原创
2357 人浏览过

这篇文章介绍的内容是关于thinkphp 隐藏index.php iis apache nginx  ,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下

针对不同的web服务器,iis7 apache nginx 可以使用不同的方法来进行配置

1.iis7 在站点根目录下添加web.config

添加内容

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

<?xml version="1.0" encoding="UTF-8"?>

 

<configuration>

 

  <system.webServer>

 

<rewrite>

 

 <rules>

 

<rule name="OrgPage" stopProcessing="true">

 

 <match url="^(.*)$" />

 

 <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>

登录后复制

重启iis生效

 

2.apache 在根目录下添加 .htaccess 添加内容:

1

2

3

4

5

6

7

8

9

10

11

<IfModule mod_rewrite.c>

 

RewriteEngine on

 

RewriteCond %{REQUEST_FILENAME} !-d

 

RewriteCond %{REQUEST_FILENAME} !-f

 

RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

 

 </IfModule>

登录后复制

重启apache 生效

 

3.对于nginx 添加内容到站点配置文件,然后重载配置文件生效

  1. 1

    2

    3

    4

    5

    6

    location / {

       if (!-e $request_filename) {

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

       break;

        }

     }

    登录后复制

 相关推荐:

thinkphp隐藏index.php/home,并允许访问其他模块

thinkphp隐藏中url的index.php,thinkphpindex.php_PHP教程

 

以上是thinkphp 隐藏index.php iis apache nginx 的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板