thinkphp 隐藏index.php iis apache nginx

  1. 亲测,IIS服务器,隐藏index.php入口文件。

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

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

  5.  
  6. 添加内容

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

  9.  
  10. <configuration>

  11.  
  12. <system.webServer>

  13.  
  14. <rewrite>

  15.  
  16. <rules>

  17.  
  18. <rule name="OrgPage" stopProcessing="true">

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

  21.  
  22. <conditions logicalGrouping="MatchAll">

  23.  
  24. <add input="{HTTP_HOST}" pattern="^(.*)$" />

  25.  
  26. <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

  27.  
  28. <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

  29.  
  30. </conditions>

  31.  
  32. <action type="Rewrite" url="index.php/{R:1}" />

  33.  
  34. </rule>

  35.  
  36. </rules>

  37.  
  38. </rewrite>

  39.  
  40. </system.webServer>

  41.  
  42. </configuration>

  43. 重启iis生效

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

  46. <IfModule mod_rewrite.c>

  47.  
  48. RewriteEngine on

  49.  
  50. RewriteCond %{REQUEST_FILENAME} !-d

  51.  
  52. RewriteCond %{REQUEST_FILENAME} !-f

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

  55.  
  56. </IfModule>

  57. 重启apache 生效

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

  60. location / {

  61. if (!-e $request_filename) {

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

  63. break;

  64. }

  65. }

  66.  

猜你喜欢

转载自blog.csdn.net/li3839/article/details/88848894