原来访问路径:http://apisy.com?r=/ali_small_lyl/v1/vote/list

美化后路径:http://apisy.com/ali_small_lyl/v1/vote/list

终端输入 open /ect/apache2

一 编辑httpd.conf 搜索“mod_rewrite” 去掉前面的# 

yii2的url美化

二 编辑/extra/httpd-vhost.conf 配置的项目 添加如下代码

<Directory "/Users/wujianyang/xampp/api_sy/app/web">
       # use mod_rewrite for pretty URL support
       RewriteEngine on
       # If a directory or a file exists, use the request directly
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       # Otherwise forward the request to index.php
       RewriteRule . index.php
    </Directory>

yii2的url美化

三 配置完成后一定要重启服务器  终端输入 sudo apachetcl restart 

四 配置完成后去项目文件中加urlManager 代码如下

'urlManager' => [
        'enablePrettyUrl' => true,
         'showScriptName' => false,
         'rules' => [],
]

yii2的url美化

五 代码文件目录 浏览器访问 http://apisy.com/ali_small_lyl/v1/vote/list 成功

yii2的url美化

相关文章:

  • 2021-05-25
  • 2022-12-23
  • 2021-08-04
  • 2021-11-11
  • 2022-12-23
  • 2021-09-10
  • 2022-12-23
猜你喜欢
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2021-11-27
  • 2021-10-18
相关资源
相似解决方案