apache 与 Nginx 隐藏 index.php 报错 No input file specified. 解决办法 设置伪静态

  • Apache
    在.htaccess中修改(如果是框架,则在public下的.htaccess)
    <IfModule mod_rewrite.c>
    Options +FollowSymlinks -Multiviews
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
    </IfModule>
  • Nginx
    在nginx.conf里增加一行
    location / {
      if (!-e $request_filename) {
          rewrite  ^(.*)$  /index.php?s=/$1  last;
      }
    }
    OJBK
本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 2

IIS 10 的伪静态应该怎么写?或者需要写吗?

1年前 评论

@scy58 没怎么用过IIS,你试一下这个方式

  1. IIS服务器web.config伪静态设置 <system.webServer>
    <system.webServer>
    <rewrite>
      <rules>
       <rule name="Imported Rule 1" stopProcessing="true">
          <match url="^/(.*)$" ignoreCase="false" />
          <conditions logicalGrouping="MatchAll">
            <add input="{R:1}" pattern="^(index\.php|images|styles|scripts|uploads|resources|robots\.txt)" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="/index.php/{R:1}" />
        </rule>
      </rules>
    </rewrite>        
    </system.webServer>
    2. httd.ini伪静态设置
    RewriteRule ^/(?:images|styles|scripts|uploads|resources)/(.*) $0 [L]
    RewriteRule ^/(.*)$              /$1/index.php/$2  [L]
1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!