开发者

Clean Url Codeigniter

I want to clear my url with codeigniter, I have these types of urls: www.ggg.c开发者_如何学Goom/index.php/page/8/name.html and I want to trasform these like www.ggg.com/index.php/name.html or www.ggg.com/name.html

Is this possible modifying the file route.php?


Actually to get rid of the index.php you need to edit out the index.php file from config.php (in your config folder inside application).

.htaccess for clean urls:

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

and to get rid of the .html just eliminate that 'suffix' again in the config/config.php file.

That should be all you need, the .html ending is just for show

As far as turning something like page/8/name into name, I would think twice about how that would work, your page or 8 most likely mean something, so your name would have to have code making it unique. My guess is that page = 8 is the value, and the name is just for the friendly url look.


Edit the routes.php file and add the line: $route['name'] = "page/8/name"; This is all explained in the docs: http://codeigniter.com/user_guide/general/routing.html To remove the index.php you will need a .htaccess file. There is an example in the ci docs or google it and you will find loads of tutorials. I'm sure there are even some examples here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜