CodeIgniter - removing index.php - codeigniter

Im having some trouble removing the index.php thing on my CI install, the current .htaccess im using is as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
My CI install is back from the public_html directory and i have changed the config to
$config['index_page'] = "";
So my CI looks like the following
/core-1.7.3
/public_html/index.php
When i type the url i get the 404, but when i put index.php in front of it, it works fine :S
Im confused

Hi
I ve installed that 1.7.3 and this .htaccess worked with this URL-
/CodeIgniter_1.7.3/public_html/welcome
.htaccess->
RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Work through Avisek Chakraborty's comment and make sure you've done them all, but
it sounds to me like you don't have mod_rewrite installed correctly.
Make sure it is by using the following test:
http://www.wallpaperama.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html
It is written for windows but you should get the idea.
If it doesn't work then install mod_rewrite and try again.

Also try to change this:
$config['uri_protocol'] = “REQUEST_URI”

You need the FollowSymLinks directive for .htaccess rewrites ...
Options Indexes FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
The Options directive is in The Apache Docs

Related

Renaming index.php in the htaccess in codeigniter

I want to rename the index.php in the htaccess file which I used for removing the long url, I renamed index.php to main.php, this is because of hacker overwriting my index.php.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php
#controller, previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^CI_System.*
RewriteRule ^(.*)$ /cacworldwide/main.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends
#the request to cacworldwide/main.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /cacworldwide/main.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to main.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /cacworldwide/main.php
</IfModule>
Simply, following lines would solve your problem
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /cacworldwide/main.php/$1 [L]
</IfModule>

codeigniter htaccess help needed

My Site:
Why is my .htaccess file not working. My framework is CodeIgniter
Options -Indexes
Options +FollowSymLinks
RewriteEngine On
RewriteBase http://core01.0fees.net/exam/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
#When your application folder isn't in the system folder
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
Try to change this line:
RewriteBase http://core01.0fees.net/exam/
To this:
RewriteBase /exam/
RewriteBase option use relative path from web root.
Try this i use it is working fine for me.
asset is the name of my application folder you can change it to your own.
RewriteEngine on
RewriteCond $1 !^(index\.php|uploads|images|css|js|lib|img|bootstrap|favicon|robots\.txt)
RewriteRule ^(.*)$ /asset/index.php/$1 [L]
if you're working on linux environment try to lowercase first letter of file (home/home.php)
linux environment is case sensitive Home.php and home.php are not same thing in linux. your problem is most probably this

Remove index.php from URL

I am using Codeigniter 2.1.0 and to remove index.php from url I follow Codeigniter 2.0.0
but it does not work for me. Actually my web application url is
http://localhost/my_site/admin/index.php/users
and I want
http://localhost/my_site/admin/users
Hi Sajid I used below code try I may be it will solve your problem.
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /your_folder/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteRule ^index\.php(.+) $1 [R=301,L]
And don't forget to open your configuration file (application/config/config.php) and edit the following two options:
$config['base_url']
$config['index_page']
You just need to create .htaccess file in project folder and write:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
#And You don't need to define in base_url in config file:
$config['base_url'] = '';// blank it.
I hope it will work perfectly ...

Codeigniter - removing index.php

I downloaded MyClientBase application which is based on code igniter. After the installation, I looked at the MyClientBase's website but the index.php is still there by default.
I tried to remove the index.php using the tips in codeigniter's user guide but it doesn't work.
Is there any solution out there for this issue? Thank you
I use the following .htaccess file to remove index.php. I'm not sure which one the user guide specifies, but I found this to be working perfectly:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|(.*)\.swf|images|robots\.txt|css|docs|cache)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
Also remove 'index.php' from your config.php file. Good luck!
i don't know if it will help but, i use this to remove my index.php from codeigniter url, create a file named .htaccess and put it to your codeigniter folder.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]

mod_rewrite for codeIgniter

Has anybody in the history of the internet and web development, been able to get rid of the "index.php" with mod_rewrite in codeIgniter.
I've been trying for several days now and nothing seems to work.
I'm using this one (in .htaccess file):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
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]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Not sure where I got it but it works for my codeigniter install, local and live. Don't forget to set $config['index_page'] = ''; in your config file.
For mod_rewrite use the following in your .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
If your codeigniter instance is running in a subdirectory then use the rewrite base command before the RewriteRule
RewriteBase /subdirectory/
Then set
$config['index_page'] = '';
In the config file.
You might have your .htaccess file in the wrong place. CodeIgniter has a default .htaccess placed in the applications folder, which I mistakenly took for the one I should edit.
You actually need to create a new .htaccess under the root folder. So not code_igniter/applications/.htacces...but code_igniter/.htaccess
Hope this helps.
Yes, I configured it under Linux using the instructions from here. However, I configured it via httpd.conf instead of using .htaccess.
I have used the settings provided above and they always worked - unless I did not have mod_rewrite enabled.
If you are having issues check to ensure you have mod_rewrite enabled. If you do not it will not matter what you put into .htacess or your Apache config

Resources