

How to delete index.php from a CodeIgniter URL?
source link: https://www.codesd.com/item/how-to-delete-index-php-from-a-codeigniter-url.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to delete index.php from a CodeIgniter URL?
I am new to CodeIgniter. I have an XAMPP server on Windows 8. Everything is fine, but the problem is about my URL, it doesn't look friendly. It looks like localhost/ci/index.php/site/home
(where ci
is my root folder for CodeIgniter). I want to make the URL more clean, like localhost/ci/home
, how can I do it?
My CodeIgniter version is 2.1.2.
I have done some research already, but in most of the cases it says to change the .htaccess
file of CodeIgniter. But I have nothing in the .htaccess
file; it's empty, except the line "Deny from all".
You can do this, in config/config.php
:
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST']; //you can also leave blank this CI tend to find this by himself
$config['index_page'] = '';
And try the following .htaccess
. I use it for many sites, and it satisfies me.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
If it is not working yet, use a phpinfo();
and check if mod_rewrite is enabled
. If it is not enabled, you can follow the instructions in Stack Overflow question How do you enable mod_rewrite? to enable that.
If it is not working yet and mod_rewrite is enabled
yet, you can try to switch these in config/config.php
:
$config['uri_protocol'] = 'AUTO'; //If not working, try one of these:
'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
Recommend
-
106
Nowadays lots of PHP frameworks like CodeIgniter, Laravel and Yii are being used for websites development. If you are using PHP for your web application....
-
112
-
11
CodeIgniter用钩子实现基于URL的权限控制 2012-04-03 21:08:00 基于URL权限系统: 例如游客只能访问音乐模块的index,list,search方法。而注册用户除上述功能之外还能访问create,update,delete方法。...
-
10
CodeIgniter去掉url中的index.php 2012-03-26 18:04:00 RewriteEngine命令需要rewrite mod的支持 $>cd /etc/apache2/mods-enabled 切换到apache下的mods-enabled目录 $&g...
-
10
Codeigniter Load the parameter at the index in the default controller according to the URL parameter advertisements I want to load a variable...
-
8
Mod rewrite to delete the file name of the url advertisements If I have a file, let's say rec-view.php, then I can call it by this URL...
-
6
How to delete Elasticsearch Index data with curlIn Elasticsearch, an index is similar to a database in the world of relational databases. It goes something like this:MySQL => Databases => Table...
-
8
Remove index.php from the URL in Laravel ...
-
13
How to Remove index.php from URL in Laravel 10326 views 1 year ago Laravel In this article, i will share with you h...
-
5
How to Delete an Elasticsearch Index: Best Practices Live Solr Online Training starting on June 22! See all classesTabl...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK