zoukankan      html  css  js  c++  java
  • 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;
        }
  • 相关阅读:
    Shiro【常用的自定义】
    Shiro【重要概念总结】
    Shiro【自定义Realm实战】
    Shiro【内置Realm实操】
    Shiro【快速上手】
    Shiro【初识】
    面向对象【抽象类和接口的区别】
    面向对象【多态中的成员访问特点】
    Kafka2.12-2.5.0在windows环境的安装 启动 通信测试
    CentOS.iso 下载地址收纳整理
  • 原文地址:https://www.cnblogs.com/zhengluwei/p/8214006.html
Copyright © 2011-2022 走看看