关于tp5 PATHINFO的URL重写

官方给出的Apache重写规则php

<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>apache

这个规则在apache fastcgi模式下会致使No input file specified.iview

修改为优化

RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]code

地址就正常重写。server

官方给出的Nginx 重写规则在站点的vhosts.conf中修改ci

location / { // …..省略部分代码 if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; } }get

其实质是将URL转化为兼容模式input

http://serverName/index.php(或者其它应用入口文件)?s=/模块/控制器/操做/[参数名/参数值...]it

以解决老版本Nginx不支持PATHINFO模式

高版本可优化规则为,固然能够不改

location / {// …..省略部分代码
          if (!-e $request_filename) {
            rewrite  ^(.*)$  /index.php/$1  last;
          }
    }
相关文章
相关标签/搜索