简体   繁体   中英

Codeigniter + URL replacement issue

The scenario is I have to replace the http://www.example.com/index.php/controller/argument by http://www.example.com/controller/argument .

If somebody enter the index.php , mean uses 1st url then it should redirect to 404 error page.

As I am new on codeigniter, so can somebody please tell me how much ways are to implement this ? and what would be the best? Should I go for .htaccess or only route.php is sufficient to implement this?

You can find an answer in the documentation here . But basically all you have to do is to create an .htaccess file in your root directory. Mine looks like this: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?/$1 [L]

EDIT:

All you have to do: - Rename index.php in the root directory to something else; - Update /application/config/config.php where it says $config['index_page'] to use the newly renamed file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM