START:
PageController->actionCategory () (
echo 'id is'. $ _GET [' id '];
)
urlManager rule in config:
'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'rules'=>array( 'pages/category/<id:d+>' => 'pages/category' ) )
.htaccess is std:
# Turn on URL rewriting RewriteEngine On # Installation directory # RewriteBase /_yii/ # Protect application and system files from being viewed RewriteRule ^(protected) - [F,L] # Allow any files or directories that exist to be displayed directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Rewrite all other URLs to index.php/URL RewriteRule .* index.php/$0 [PT,L]
It is works!
'http://localhost/pages/category/3' -> result: 'id is 3'
QUESTION
Also required:
http://localhost/news/ -> http://localhost/pages/category/3
How do I implement this?
urlManager rule: ('news' =>' pages/category/id/3') befor/after first rule — does not work. 404 error: The requested controller "pages/category/id" does not exist.
and
urlManager rule: ('news' =>' pages/category/id/3/') befor/after first rule — does not work. 404 error: The requested controller "pages/category/id/3" does not exist.
Maybe do it in .htaccess, but how? O,…,o