yii的urlManager设置

yii的urlManager设置
Apache服务器下yii的urlManager设置
step1:Yii的配置文件config/main.php中
'components'下增加
 1  ' urlManager ' => array (
 2       ' urlFormat ' => ' path ' ,
 3       ' showScriptName '   =>   false ,
 4       ' rules ' => array (
 5           ' urls.js '   =>   ' workspace/urls ' ,
 6           ' env.js '   =>   ' workspace/env ' ,
 7                   ' <controller:\w+>/<id:\d+> ' => ' <controller>/view ' ,
 8                   ' <controller:\w+>/<action:\w+>/<id:\d+> ' => ' <controller>/<action> ' ,
 9                   ' <controller:\w+>/<action:\w+> ' => ' <controller>/<action> ' ,
10              ) ,
11          ) ,
step2:开启Apache的配置文件httpd.conf中LoadModule rewrite_module modules/mod_rewrite.so和AllowOverride属性设置为All
step3:编写一个.htaccess文件放在app的根目录,添加以下几行到文件中
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

你可能感兴趣的:(yii的urlManager设置)