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
posted on 2011-07-26 14:20
黃劍父 閱讀(5315)
評論(0) 編輯 收藏 引用 所屬分類:
web開發(fā)