apache htaccess 规则配置

来源:7-6 使用UrlManager处理项目URL路由美化

lph0

2017-08-14

这个是老师配置的

location / {

    # index.php?r=index/index

    # index.html

    try_files $uri $uri/ /index.php?$args;

}

,但是在apache中我在index.php 同级目录创建 .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

这是我的web.php 配置 

'urlManager' => [
   'class' => 'yii\web\UrlManager',
   'enablePrettyUrl' => true,
  // 'enableStrictParsing' => false,  //不启用严格解析
   'showScriptName' => false,
  'suffix' => '.html',
   'rules' => [
       '<controller:(index|cart|order)>' => '<controller>/index',
       'auth' => 'member/auth',
       'product-category-<cateid:\d+>' => 'product/index',
       'product-<productid:\d+>' => 'product/detail',
       'order-check-<orderid:\d+>' => 'order/check',
       [
           'pattern' => 'admin',
           'route' => '/admin/default/index',
           'suffix' => '.html',
       ],

   ],
],

shop.imooc.com/inde.php/index.html 访问错误


写回答

1回答

Jason

2017-08-17

先把urlManager的规则注释掉,看看pathinfo模式生效不

0
2
Jason
回复
lph0
恩,把rules规则注释掉,单纯看看pathinfo能不能生效,看看site/index这样能不能访问
2017-08-23
共2条回复

Yii2.0进阶版 高级组件ES/Redis/Sentry优化京东平台

进阶更高阶的Yii 2.0开发,获得2-3年yii 2.0实战经验

514 学习 · 210 问题

查看课程