Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
590 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...