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 ...
Related
I know this question has been asked many times but have tried all the solutions but invain
My Config file is as follow
$config['base_url'] = 'http://immodernafrican.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
.htaccess file is
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|static|robots\.txt|favicon\.ico|uploads|googlexxxxxxxx\.html|mobile.html)
RewriteRule ^(.*)$ index.php/$1 [L]
Changed
AllowOverride None
To
AllowOverride All
but still my url works with index.php
immodernafrican.com/index.php/AncientHistory
other than that it gives 404 error
immodernafrican.com/AncientHistory
Just Change your .htaccess to this
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Your .htaccess file will be
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
#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>
Config file
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
Follow this
For Server
Activate mode_rewrite module
sudo a2enmod rewrite
Restart the apache
sudo service apache2 restart
edit 000-default.conf
sudo nano /etc/apache2/sites-available/000-default.conf
Search for “DocumentRoot /var/www/html” and add the following lines directly below:
<Directory "/var/www/html">
AllowOverride All
</Directory>
Save and exit the nano editor via CTRL-X, “y” and ENTER.
Restart the server:
sudo service apache2 restart
in config.php
$config['base_url'] = 'http://immodernafrican.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
in routes.php
$route['default_controller'] = "YOUR_DEFAULT_CONTROLLER";
htaccess file
<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
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>
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>
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
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]
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