How to Remove index php from CodeIgniter
كيفة إزالة ملف index.php من رابط في CodeIgniter
Remove index.php from this
http://localhost/codeigniter/index.php/news/articles
|
to look like this
http://localhost/codeigniter/news/articles
|
Step By Step with Image.How to Remove index.php from CodeIgniter URL
For wamp,xampp windows users.
after install the
codeigniter in
wamp,xampp go to www folder to locate the folder just press wamp icon in windows bar and press www directory
after locate the www directory you will see your website application.in my pc my folder which contain
codeigniter framework is name
codeigniter so choose your folder.
www\codeigniter this my framework folder
remember i am work in my folder not your ok just go to where is your folder.
as image show
there's arrows in image with number.
- arrow with number 1 this indicate to my codeigniter physical path or codeigniter directory and we are open it from previous step as image show.
- arrow with number 2 indicat to application system which contain config folder also their is file named .htaccess so due to windows prevent you to create file with no name just extention so the easiest way to create this file just copy it from application folder to main codeigniter folder ,you do not need to use cmd to create.
- arrow with number 3 from application folder copy .htaccess file here.as expline in privous step.
after we copy
.htaccess file open by
notepad delete all code .write or copy lines.
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /codeigniter/index.php/$1 [L]
|
you see the word in red which it codeigniter this word is my application framework just replace it with yours
if yours for example news just replace the codeigniter and put news to be like this
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /news/index.php/$1 [L]
|
this code in .htaccess file in main folder of your application save file and close it.
next step configuration the config.php file so the config.php file is located in application folder as the second image show and the second arrows show .which from this folder we are copy .htaccess file to main folder as explain.now open the config.php by notepad and do this. make ever lines listed below look like the below line.empty
a$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'auto';
|
in some cases if auto not work after we do all steps replace it with REQUEST_URI but do not do it now until finish the final step.so save and close file.
final step edit httpd.conf to open this file from wamp icon click in apache choose httpd.conf
it will open in notepad
|
locate httpd.conf file |
just looking for this line and remove # hash character from it
#LoadModule rewrite_module modules/mod_rewrite.so
|
to be like
LoadModule rewrite_module modules/mod_rewrite.so
|
save and close file.
|
LoadModule rewrite_module modules/mod_rewrite.so |
now restart server from wamp server icon choose restart server
Enjoy with new url structure without index.php.
if like post follow us thanks
التسميات: PHP Codeigniter