codeIgniter Index.php Removal from URL - codeigniter

I know this question has been asked one thousand time. But I have problem applying it to my project however.
What I do: I have copied the following code (suggested by CI Docs) in .htaccess file in my application folder:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
PROBLEM: it does not work and it throws 404 or Internal Error. I also have tries creating new .htaccess file in my root folder, or copying the above code in system folder's .ht . none of them works. 404 or internal error are inervitable

paste the following code in your htaccess file inthe root folder
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
and the in the config.php file change the line with
$config['index_page'] = '';
please let me know if you face any problem.

Try this
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
and in config.php
$config['index_page'] = '';

Thanks everybody. it is done. The problem was that I had not activated the APACHE rewire_module
Sorry if I wasted your time.
thanks

Related

CodeIgniter routes not taking effect

I just copied a codeigniter project from one folder to another in my XAMPP htdocs. These two projects contain exactly the same code, they're just in different directories.
In the copied project, the default_controller works fine but none of my routes work.
my routes:
$route['default_controller'] = 'home';
$route['404_override'] = '';
$route['dashboard'] = 'dashboard';
The index file is located at localhost/project/www
If I go to localhost/project/www/dashboard, I get a 404.
But if I do this:
$route['404_override'] = 'dashboard';
Then the dashboard controller loads correctly when I go to localhost/project/www/dashboard (or any other path, which would give a 404, of course)
The problem is not in the .htaccess file, since it's just generic:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Like I said, the code has just been copied from one directory to another. Any ideas as to what is preventing my routes from working properly? Have I missed something?
EDIT
After setting the 404_override and removing it again, the routes magically worked again. Everything is fine.
If anyone could shed a light on why this has happened, that might help the next guy who gets in this situation. But for me, the problem is resolved.
OK, the problem was that I had used uppercase for the name of the copied project, but was trying to access it with lowercase on a system that discerns between these two.
So, stupid
i think problem is you were using doing like this
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
instead you try it
RewriteEngine On
RewriteBase /www/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

How to remove domainname.com/index.php/photos from URL

How to remove domainname.com/index.php/photos from the pyrocms URL. I tried to remove index.php from $config['index_page'] = 'index.php';. But it does not work. Can anyone help please. Is there anything i have to do during the installation time.?
You will have to use an .htaccess file in the root folder too (if you are using apache or php built-in webserver).
Here is the one I use: https://gist.github.com/taiar/2424263
Here is the reference from the oficial docs: https://ellislab.com/codeigniter/user-guide/general/urls.html
You need to write a .htaccess rule
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Codeigniter Index file issue

I have already worked in the CI. But this time when i remove the index file. I am getting 404 error. But i did everything correctly. Here is the settings i have done.
.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|files\/images|files\/javascripts|files\/stylesheets|files\/swf|files\/upload)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /qrout/index.php/$1 [L]
Config File
$config['base_url'] = 'http://webscarlets.in/projects/';
$config['index_page'] = '';
I hope above settings are all correct. And i have tried added this 'qrout' folder in the base url still it's not working
Here is the website link
http://webscarlets.in/projects/qrout/welcome
Kindly guide me to solve this issue.
Thanks to all.
Try to use this condition .....ITs working for me
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
It looks like your rewrite condition is targeting js files and things like that. Those files don't need the index.php in their path. Only your Codeigniter files will.
I'd rework that conditional statement.

CodeIgniter - Getting rid of the index.php in different circumstances

I have my CodeIgniter install one path back from the public_html directory so its not in the root of my web folder.
Can someone suggest .htaccess code that will get rid of the index.php in the URL based on this?
I have tried a few in the past and they havent worked, im quite stumped.
Cheers,
I have tried the following code
RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Have you put the index.php one folder back from public_html as well?
I would suggest not doing so, there should be no harm in making the index.php public, but well worth hiding the rest.
Put the index.php back under public_html and modify it like so:
Line 56:
$system_path = '../system';
Line 72:
$application_folder = '../application';
Of course if you have them in another folder then change the path accordingly.
EDIT:
Sorry I should note that afterwards your htaccess should look like this:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
try adding
RewriteBase /public_html/
above the first RewriteCond.
but I'm not an .haccess wizard by any means.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]

codeigniter removing index.php (possible problem with host)

Hi everyone I'm having some problems when removing index.php in CodeIgniter.
I created my application locally and it works fine but when I uploaded it, removing index.php doesn't seem to work.
I have a feeling this could have something to do with my host, it's not the best and I've had problems before. It's hosted on Fatcow.
So..
all my CodeIgniter files are located in a sub-dirctory called outfitr. e.g
<root>/outfitr/
I have my .htaccess file located in this folder with the following taken from the CI wiki:
EDITED
RewriteEngine On
RewriteBase /outfitr/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
changes fo my config.php look like the following. I have enabled query strings as I need them for a section of my application.
$config['base_url'] = "<host>.com/outfitr/";
$config['index_page'] = "";
...
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = TRUE;
Any help would be great. As I said I think it might have something to do with the host Fatcow.
I have tested mod_rewrite, following the steps on the following page and it seems to be enabled.
http://www.wallpaperama.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html
ok so after some trial and error I finally got it working. I setup my .htaccess file as follows. Note the '?' in RewriteRule.
RewriteEngine On
RewriteBase /outfitr/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
Then in config.php I set
$config['uri_protocol'] = 'REQUEST_URI';
Think this is down to the way some hosts setup their mod_rewrite module. Dreamhost and hostgator have the same problem.
http://codeigniter.com/wiki/mod_rewrite/
If your installation is not in the server root you will need to amend the RewriteBase line from “RewriteBase /” to “RewriteBase /folder/”
The current .htaccess you have is re-routing all requests to /index.php, which as you said yourself is not there. You want them to route to /outfitr/index.php.
You can do this by changing the RewriteBase /outfitr/
If not, please give more detail.

Resources