开发者

URI Routing Help CodeIgniter

I am new to codeigniter, infact using it first time. I am editing a script developed using CodeIgniter. It is GroupScript - clone of famous Groupon. In this script, there is a facility to select different cities. By default, links to different cities are like :

domain.com/frontend/profile/selectCity/[city_id]

I want some uri routing example so that i can redirect domain.com/[city_id] to

domain.com/frontend/profile/selectCity/[city_id]

I studied some examples that helped also. The best far i could get was

domain.com/index.php/[city_id]

was being redirected to

doma开发者_运维百科in.com/frontend/profile/selectCity/[city_id]

Code used was : $route[’(:num)’] = “frontend/profile/selectCity/$1”;

I am not able to eliminate the index.php in url. Any help would be appreciated. If i could eliminate index.php stuff from url then I am done.

Demo groupscript is here to understand what i expect : demo.groupscript.net


I haven't used the routing feature, but removing the index.php can be done with .htaccess files (if you are on apache). See the section titled Removing the index.php file in this part of the user guide


Typically you would want something like:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

RewriteCond $1 !^(index\.php|images|robots\.txt|javascript|css)
RewriteRule ^(.*)$ /index.php/$1 [L]

This will redirect all request within your .htaccess file.


Don't forget to set the default index to '' in config.php under:

"If you are using mod_rewrite to remove the page set this variable so that it is blank."


Remove "index.php" to make it blank in your config.php file. The default file name will be removed from the URL then

$config['index_page'] = '';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜