http://xxx.xxx.xxx/index.php?r=post/show&id=1&content=xxx............
我們可以透過URL Management讓網址更簡潔
在config/main.php中的components加入
'urlManager'=>array(
'urlFormat'=>'path',
),
另外要隱藏index.php,可在index.php同層目錄下建立.htaccess檔,檔案內容:
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的action
http://xxx.xxx.xxx/post/show/id/content/xxx
註:PHP mod_rewrite要掛起來
註:PHP mod_rewrite要掛起來
沒有留言:
張貼留言