Home > Backend Development > PHP Tutorial > thinkphp hide index.php iis apache nginx

thinkphp hide index.php iis apache nginx

不言
Release: 2023-03-23 21:56:02
Original
2273 people have browsed it

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

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

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

添加内容

<?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>
Copy after login

重启iis生效

 

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

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

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

 </IfModule>
Copy after login

重启apache 生效

 

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

  1. location / { 
       if (!-e $request_filename) {
       rewrite  ^(.*)$  /index.php?s=$1  last;
       break;
        }
     }
    Copy after login

 相关推荐:

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

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

 

The above is the detailed content of thinkphp hide index.php iis apache nginx. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template