Codeigniter controller/views 'pretty uri'

2019-09-14 21:59发布

问题:

I'm a complete Codeigniter noob.

I think I have everything setup properly, and the pages display when I go to:

http://www.example.com/index.php/pages/view/my_page

but I get an Apache 404 error when I visit without the index.php file:

http://www.example.com/pages/view/my_page 

Is there anything obvious I'm missing? .htaccess rules, or a change in the controller?

回答1:

By default, the index.php file will be included in your URL

You can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the "negative" method in which everything is redirected except the specified items:

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


标签: codeigniter