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

Categories

0 votes
606 views
in Technique[技术] by (71.8m points)

php - How to Call codeigniter controller function without url without index

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

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

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...