zoukankan      html  css  js  c++  java
  • 服务器去除 index.php 方法

    ngnix服务器,进入:nginx/conf/vhosts.conf

    server {
            listen       80;
            server_name  www.x.com x.com;
            root   "C:RuningPHPTutorial";
            location / {
                index  index.html index.htm index.php;
                #autoindex  on;
            }
    /** 添加的代码 *****/
            if (!-e $request_filename)
           {
              rewrite ^/(.*)$ /index.php?/$1 last;        break;
            }
    /** 添加的代码 *****/
            location ~ .php(.*)$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_split_path_info  ^((?U).+.php)(/?.+)$;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  PATH_INFO  $fastcgi_path_info;
                fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
                include        fastcgi_params;
            }
    }

    apache服务器,根目录添加 (.htaccess)文件,添加内容如下:

    <IfModule mod_rewrite.c>
     RewriteEngine on
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
    </IfModule>
  • 相关阅读:
    DOM面试题【三】
    JS面试题【二】
    移动端面试题【一】
    【python】mysql查询错误告警的处理
    硬币排成线
    书籍复印
    分割回文串
    分割回文串 II
    完全平方数
    俄罗斯套娃信封问题
  • 原文地址:https://www.cnblogs.com/qingsong/p/12198544.html
Copyright © 2011-2022 走看看