php - YII URL how to generate new URL -



php - YII URL how to generate new URL -

i have 1 site in want url siteurl/about.html.

i have changed code in config/main.php when login site gets session expired when navigate other page.

if comment code 'showscriptname'=>false in config/main.php file, work fine , login session saved , not expired url becoming siteurl/index.php/about.html

but want url about.html.

i have 1 controller game alternative url like: http://www.demo.com/index.php/games/info/9.html want url siteurl/black-hook.html in "black-hook" name of game.

'urlmanager'=>array( 'urlformat'=>'path', 'showscriptname'=>false, 'rules'=>array( '<action>'=>'site/<action>', '<view>'=>'array('site/page')', '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>' ), ),

*siteurl = http://www.demo.com

first .html appended pages need utilize false url suffix alternative in urlmanager

this can done adding 'urlsuffix' =>'.html' urlmanager config

'urlmanager'=>array( 'urlformat'=>'path', 'showscriptname'=>false, 'urlsuffix'=>'.html', 'rules'=>array( '<action>'=>'site/<action>', '<view>'=>'site/page', '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>' ), ),

secondly hiding index.php (called entry script) in url in add-on changing configuration here need alter configuration in apache/nginx server.

create file /.htaccess next content , save it

rewriteengine on # if directory or file exists, utilize straight rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d # otherwise forwards index.php rewriterule . index.php

next verify if allowoveride all there app directory in apache configuration file can add together above configuration straight apache configuration file using directory element without using .htaccess . note: work need have rewrite engine enabled in apache config, can next set of commands

a2enmod rewrite

finally restart apache2 after

/etc/init.d/apache2 restart

or

service apache2 restart

php yii url-rewriting yii-routing

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -