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”

2

3 Answers 3

0

This should work

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ CI/index.php/$1 [L]
Sign up to request clarification or add additional context in comments.

2 Comments

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. stackoverflow.com/questions/21062290/…
Even adding RewriteBase/ CI ..It doesn't work, any other solution.
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]

2 Comments

just save this in your ht access file and try
Thanks for the answer but it doesn't work .. No input file specified.
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']).'/');

9 Comments

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 .!!
You need to use the last .htaccess for godaddy. It is a special case.
Do i need to inckude the folder name ci in the htaccess code u mentioned above
No you do not need to include any directory name. It supposed to work perfectly.
No input file specified :-( ... But it works fine in localhost
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.