YII apache/nginx 配置伪静态的 发布日期:2016-07-20 13:59:35     博主推荐★
//apache下的.htaccess文件内容

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
//nginx配置如下
//主要是:
//location / {     
//   # Redirect everything that isn't a real file to index.php
//   try_files $uri $uri/ /index.php?$args;
// } 
//完整配置如下

server {   
 charset utf-8;  
 client_max_body_size 128M;
 listen 80;## listen for ipv4
 #listen [::]:80 default_server ipv6only=on;
 ## listen for ipv6

   
 
 server_name mysite.local;
 root       /path/to/basic/web;
 index       index.php;
 access_log  /path/to/basic/log/access.log;
 error_log   /path/to/basic/log/error.log; 
 
 location / {     
   # Redirect everything that isn't a real file to index.php
   
   try_files $uri $uri/ /index.php?$args;
  
 } 
 location ~ \.php$ {   
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; 
     fastcgi_pass   127.0.0.1:9000;    
     #fastcgi_pass unix:/var/run/php5-fpm.sock;
  
     try_files $uri =404; 
  }

 


 YII2项目模块下config/main.php在components里面添加节点,即可

 

'urlManager'=>[
    'enablePrettyUrl' => true,
    'showScriptName' => false, //去除index.php
    'suffix'=>'.html', //加上.html
    'rules'=>array(
    ),
],


博文地址:https://blog.ahamu.cn/blog/detail.html?id=14
   
推荐文章
  • 1
    sysbench
    2020/07/08
  • 2
    phper转java记录篇-spring boot
    2020/06/10
  • 3
    thinkphp5.0使用路由之后,post请求的
    2020/05/19
  • 4
    springboot单元测试aop失效
    2020/05/15
  • 5
    脑海中的JVM
    2020/05/12
  • 6
    IDEA搜索插件时显示search results
    2020/05/12
  • 7
    spring boot 配置加载源码查找
    2020/04/20
  • 8
    通过javap命令分析java汇编指令
    2020/04/16
  • 9
    IDEA小知识:查看JVM内存使用情况的步骤
    2020/04/16
  • 10
    springboot-加载自定义的properti
    2020/04/14
  • 11
    Jenkins执行shell脚本无法启动子进程解决
    2020/04/03
  • 12
    mac idea激活找专业的
    2020/04/02
  • 13
    Jenkins + DockerSwarm 实现弹
    2020/03/31
  • 14
    mac swarm学习过程
    2020/03/31
  • 15
    spring cloud
    2020/03/18
  • 16
    JAVA开发中遇到的问题记录002
    2020/03/12
  • 17
    JAVA开发中遇到的问题记录001
    2020/03/07
  • 18
    php -i查看信息
    2020/02/23
  • 19
    phpStorm中使用xdebug工具调试dock
    2019/12/09
  • 20
    讲的比较好的B+树执行原理的文章
    2019/12/09
最喜标签
NYOJ 面试 AJAX ping CentOS 灰度算法 YII2