0

Im trying to remove index.php from the url for the past 4 days but not successful.

http://domainName.com/CI/index.php/controller-name/function/parameter

CI is the folder hosted in godaddy.

/
.htaccess
CI

After googling, I tried with the following codes but getting only a blank page or error:500 and also I didn't understand the logic. Please someone help me to find where Im going wrong.

RewriteEngine on
RewriteCond $1 !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

2nd

RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php/$0 [PT,L] 

I also changed the line in, CI/application/config/config.php

$config['index_page'] = '';

$config['uri_protocol'] = “REQUEST_URI”

Kumar Htabmas
  • 45
  • 1
  • 2
  • 11

3 Answers3

0

This should work

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ CI/index.php/$1 [L]
  • in your example you haven't used RewriteBase to set it to CI folder since in that folder your application resides. Here is an example in setting RewriteBase dynamically. It might be useful. http://stackoverflow.com/questions/21062290/set-rewritebase-to-the-current-folder-path-dynamically –  Jan 12 '15 at 06:40
  • Even adding RewriteBase/ CI ..It doesn't work, any other solution. – Kumar Htabmas Jan 12 '15 at 19:37
0

Just try this it's working means reply me

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Prasanna
  • 99
  • 3
0

Follow the following step:

  1. Change the config file like this:

    $config['index_page'] = '';

    $config['uri_protocol'] = 'AUTO';

  2. Use the following .htaccess:

RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Note: .htaccess vary depending on server. Some server (e.g.: Godaddy) need to use the following .htaccess:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

see here

Use the following code in base_url:

$config['base_url'] = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://'.$_SERVER['HTTP_HOST'].str_replace('//','/',dirname($_SERVER['SCRIPT_NAME']).'/');
Laurel
  • 5,965
  • 14
  • 31
  • 57
Ariful Islam
  • 7,639
  • 7
  • 36
  • 54
  • After changing allow ovveride in apache.conf it works fine in localhost..Still issue not solved in godaddy server, it display "No input file specified. ".. When placing ur htaccess code the url domainName.com/CI/index.php/controller-name/function/parameter changes into domainName.com/?/controller-name/function/parameter... Any help .!! – Kumar Htabmas Jan 12 '15 at 19:57
  • You need to use the last .htaccess for godaddy. It is a special case. – Ariful Islam Jan 13 '15 at 04:18
  • Do i need to inckude the folder name ci in the htaccess code u mentioned above – Kumar Htabmas Jan 13 '15 at 09:07
  • No you do not need to include any directory name. It supposed to work perfectly. – Ariful Islam Jan 13 '15 at 09:41
  • No input file specified :-( ... But it works fine in localhost – Kumar Htabmas Jan 14 '15 at 07:07
  • Could you please share your .htaccess file once again here. And please also let me know you base_url text. – Ariful Islam Jan 14 '15 at 07:16
  • Now Im exactly using the 2nd htaccess code you mentioned above.. base_url is http://domain.com/ci and $config['uri_protocol'] = 'AUTO'; – Kumar Htabmas Jan 14 '15 at 10:29
  • Even this doesn't work .. previously there are two .htaccess file in my server. one in public_html/.htaccess and another in public_html/htaccess/.htaccess ( I deleted this). Any other changes do I miss. – Kumar Htabmas Jan 16 '15 at 11:06
  • We have a pull of hosted web application done with Codeigniter and run in godaddy server without any hassle. I can't realize your case without seeing the directory structure, file structure etc. – Ariful Islam Jan 16 '15 at 12:08