Default controller/action, htaccess and dinamic pages in DB

Hello and good day.

I have a question about Yii.

I am creating a small CMS and I need to load pages from the database.

My problem is this;the site loads dynamic content from www.myweb.com/site/load.html?q=1234

This connect to the page 1234 and gets the content.

How I can delete the controller/action and convert the query to the name of the topic? like this www.myweb.com/my_topic_here.html

Thanks for your time.

Up!

any ideas?

Yah you can…

Add in .htaccess


	# 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

Change in config=>main.php


		'urlManager'=>array(

			'urlFormat'=>'path',

			'rules'=>array(

                           .....

			),

			'showScriptName'=>false,

			'urlSuffix'=>'.html',

		),

Also you can change the rules based on your requirement like this




			'rules'=>array(

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/getpriority/<category:\d+>'=>'<controller>/getpriority',


				'<controller:category>/<action:(create|index|admin)>'=>'<controller>/<action>',

				'<controller:category>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:category>/<cat:.+>/'=>'<controller>/categorypage',

				

				'<controller:article>/<action:(create|index|admin|slug|suggestTags)>'=>'<controller>/<action>',

				'<controller:article>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:article>/<art:.+>/'=>'<controller>/articlepage',

				

				'<controller:\w+>/slug/<st:.+>'=>'<controller>/slug',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

			),

Changing rules has worked.

Thanks for help!.