Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to call codeigniter controller class function Like this. but this is not working i want remove index.php from URL

enter image description here

With index.php this working well How to Remove index.php from url ?

enter image description here

I changed

   $config['index_page'] = 'index.php'; 

To

   $config['index_page'] = '';   

but it's not worked

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
588 views
Welcome To Ask or Share your Answers For Others

1 Answer

You have to do two job to remove the index.php from the URL.

1st Job -

changed the config file

 $config['index_page'] = 'index.php'; 

To

 $config['index_page'] = ''; 

(Which you have already done)

2nd Job -

You have to add a .htaccess file in your root directory and make sure that your php mod_rewrite is enabled.

For more info, please refer the RewriteRule docs.

RewriteEngine on
RewriteRule ^([a-z0-9_-]+).html$ index.php/page/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index.php|asset|robots.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Just try this. Hope it works and let me know whats going on.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...