PHP开发笔记(三)关于PHP伪静态的问题总结

Apache

第一个问题就是关于PHPStudy集成Apache环境下5.5版本以上”No input file specified“问题。

针对TP5框架,以下是.htaccess文件的配置,PHP 5.5版本以下可以正常使用。

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

然而上述配置文件切换到5.6版本以上就不可使用,直接报错“No input file specified”。修改成以下配置即可正常访问。

<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 

接下来再说一下TP5版本在nginx环境下支持PATHINFO模式和隐藏index.php的方法,本例是在centos7.0版本、nginx1.4.4版本下操作的,配置代码如下。我是直接在nginx.conf文件中进行配置的。

server {
            listen       80;
            server_name  www.abc.com;
            root  /weixin/public;
            index index.php;
            #隐藏index.php
            location / {
                  if (!-e $request_filename) {
                       #一级目录
                       # rewrite ^/(.*)$ /index.php/$1 last;
                       #二级目录
                       rewrite ^/(.*)$ /index.php/$1 last;
                     }  
            }
            location ~ \.php($|/) {
                    fastcgi_pass localhost:9000;
                    fastcgi_index index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$;  
            fastcgi_param   PATH_INFO $fastcgi_path_info;  
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
                    include  fastcgi_params;
            }
            access_log  logs/aicaiche.access.log  main;
    }

 

转载于:https://www.cnblogs.com/zhengluwei/p/8214006.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值