• 首先要在服务器配置(httpd.conf)中开启重写模块:

    #开启重写模块,将其前面的#去掉
    LoadModule rewrite_module modules/mod_rewrite.so
    #Directory中允许覆盖开启
    <Directory "${SRVROOT}/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important. Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    # Options FileInfo AuthConfig Limit
    #
    AllowOverride All #
    # Controls who can get stuff from this server.
    #
    Require all granted
    </Directory>
  • 在目录下加入服务器配置文件.htaccess
    RewriteEngine on
    
    ###############################
    # @email test@test.com
    # @author test
    ############################### #重写规则
    #如果是一个目录或者文件,就访问目录或者文件
    RewriteCond %{REQUEST_FILENAME} !-d #如果文件存在,就直接访问文件,不进行下面的RewriteRule
    RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php
  • 在框架配置项\frontend\config\main.php中加入urlManager配置项
    'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    //'suffix' => '.html',//URL后缀
    ],
  • 对了,修改完服务器配置不要忘了重启服务器,有啥错误看服务器日志,这个很关键

最新文章

  1. 网页游戏外挂辅助AMF模拟通讯必备
  2. SQL*Loader之CASE5
  3. 重绘TabControl
  4. MS Sql Server 中主从库的配置和使用介绍(转)
  5. opencv在VS2010命令行编译过程
  6. pt-query-digest 安装及使用
  7. javascript 高级程序设计 学习笔记
  8. Java虚拟机-类文件
  9. Trie树(字典树)推荐文章
  10. Node版本管理工具-NVM的安装与使用(windows系统)
  11. IIS启动应用程序池报错&quot;服务无法在此时接受控制信息&quot;
  12. spring-boot-2.0.3启动源码篇三 - run方法(二)之prepareEnvironment
  13. Jmeter之csv参数化
  14. 关于Redis缓存数据库
  15. 阿里云配置ssl证书
  16. Linux进程概述
  17. (转)linux下压缩和归档相关命令tar,zip,gzip,bzip2
  18. 盒子模型 以及CSS的box-sizing属性。
  19. 第二篇、HTML
  20. hdu 3478 Catch 二分图染色

热门文章

  1. Python短路原则
  2. linux上 查看mysql的binglog日志
  3. “全栈2019”Java第十七章:赋值运算符和算术运算符
  4. 洛谷P5205 【模板】多项式开根(FFT)
  5. [bzoj2816][ZJOI2012]网络(LCT,splay)
  6. 并发编程---线程 ;python中各种锁
  7. 【算法】C++用链表实现一个箱子排序附源代码详解
  8. 二叉搜索树 思想 JAVA实现
  9. ES6 (一)变量声明方法 &amp; 解构赋值
  10. SpringBoot 启动的时候提示 Field *** in *** required a bean named &#39;entityManagerFactory&#39; that could not be found.