最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

yii 隐藏index.php的方法

来源:懂视网 责编:小采 时间:2020-11-27 13:59:24
文档

yii 隐藏index.php的方法

yii 隐藏index.php的方法:yii隐藏index.php的方法:首先在配置文件main.php中添加urlManager;然后在index.php同级目录下新建.htaccess文件;最后配置nginx.conf和vhosts.conf即可。推荐:《PHP视频教程》该方法适用于所有品牌电脑。Yii 隐藏 index.php(Apache
推荐度:
导读yii 隐藏index.php的方法:yii隐藏index.php的方法:首先在配置文件main.php中添加urlManager;然后在index.php同级目录下新建.htaccess文件;最后配置nginx.conf和vhosts.conf即可。推荐:《PHP视频教程》该方法适用于所有品牌电脑。Yii 隐藏 index.php(Apache

推荐:《PHP视频教程》

  • 该方法适用于所有品牌电脑。

  • Yii 隐藏 index.php(Apache + nginx)

    1、在配置文件 main.php 中添加

    'urlManager' => [//用于URL路径化'enablePrettyUrl' => true,//指定是否在URL在保留入口脚本 
    index.php'showScriptName' => false,],

    2.1、Apache 配置

    同时还要在index.php同级目录下新建.htaccess文件

    #表示开启重写引擎
    RewriteEngine on
    #请求的文件或路径是不存在的,如果文件或路径存在将返回已经存在的文件或路径
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php

    .htaccess文件解释

    概述来说,htaccess文件是Apache服务器中的一个配置文件,它负责相关目录下的网页配置。

    通过htaccess文件,可以帮我们实现:网页301重定向、自定义404错误页面、改变文件扩展名、 允许/阻止特定的用户或者目录的访问、禁止目录列表、配置默认文档等功能。

    2.2、nginx 配置

    ① nginx.conf 配置

    worker_processes 1;
    events {
     worker_connections 1024;
    }
    http {
     include mime.types;
     default_type application/octet-stream;
     sendfile on;
     keepalive_timeout 65;
     fastcgi_connect_timeout 300;
     fastcgi_send_timeout 300;
     fastcgi_read_timeout 300;
     fastcgi_buffer_size 128k;
     fastcgi_buffers 4 128k;
     fastcgi_busy_buffers_size 256k;
     fastcgi_temp_file_write_size 256k;
     gzip on;
     gzip_min_length 1k;
     gzip_buffers 4 32k;
     gzip_http_version 1.1;
     gzip_comp_level 2;
     gzip_types text/plain application/x-javascript text/css application/xml;
     gzip_vary on;
     gzip_disable "MSIE [1-6].";
     server_names_hash_bucket_size 128;
     client_max_body_size 100m; 
     client_header_buffer_size 256k;
     large_client_header_buffers 4 256k;
     server {
     listen 80;
     server_name localhost;
     #你的项目根目录
     root "D:/Program Files/phpStudy/WWW";
     location / {
     index index.html index.htm index.php l.php;
     autoindex off;
     }
     error_page 500 502 503 504 /50x.html;
     location = /50x.html {
     root html;
     }
     location ~ \.php(.*)$ {
     #你的项目根目录
     root "D:/Program Files/phpStudy/WWW";
     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;
     }
     }
     include vhosts.conf;
    }

    ② vhosts.conf 配置

    server {
     listen 80;
     #你的虚拟主机名
     server_name www.luluqi.com ;
     #虚拟主机根目录
     root "D:/Program Files/phpStudy/WWW/luluyii/web";
     location / {
     index index.php index.html index.htm;
     #nginx ignore index.php
     if (!-e $request_filename){ 
     rewrite ^/(.*) /index.php last; 
     } 
     }
     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;
     }
     
    }

    文档

    yii 隐藏index.php的方法

    yii 隐藏index.php的方法:yii隐藏index.php的方法:首先在配置文件main.php中添加urlManager;然后在index.php同级目录下新建.htaccess文件;最后配置nginx.conf和vhosts.conf即可。推荐:《PHP视频教程》该方法适用于所有品牌电脑。Yii 隐藏 index.php(Apache
    推荐度:
    标签: 方法 Yii index.php
    • 热门焦点

    最新推荐

    猜你喜欢

    热门推荐

    专题
    Top