The following code is in my .httaccess file.
#write your project folder name as rewritebase
RewriteBase /Codeignitor3D/
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*) index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+) index.php?/$1 [L]
It's give the 500 internal server error
Try this Rule:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
In your config.php file,
//Find
$config['index_page'] = "index.php"
//and replace it with
$config['index_page'] = ""
Steps to remove index.php from url codeigniter:
Config changes: Go to “application/config/config.php”
Find below code:
$config['index_page'] = 'index.php';
Replace with the below code:
$config['index_page'] = '';
.htaccess changes: If you not have any htaccess create new and place it on your root.
Note: if you have codeigniter in subdirectory change RewriteBase / to RewriteBase /subdir/
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Now open your site pages you will found clean url with no index.php. so your all url looks like http://example.com/controller/method. Now any of HTTP request for index.php will be treated as a request for your index.php file.
If still issue: Need to apply one more config changes.
Go to “application/config/config.php”
Find below code
$config['uri_protocol'] = 'AUTO';
Replace with the below code
$config['uri_protocol'] = 'REQUEST_URI';
Now you have fully done to remove index.php from url codeigniter and getting clean url in codeigniter.
Make sure mod_rewrite is installed and enabled
Make sure apache's site config file allows the use of .htaccess
Check apache's error log as well as PHP's error log, since you are getting 500
Review http://www.codeigniter.com/user_guide/general/urls.html
Related
i have posted question yesterday about removing index dot php from codeigniter path but problem not solved... so can any one come on to team viewer and solve my problem...? thanks in anticipation
my .htaccess in root folder
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
You have to move your .htaccess file to that directory where index.php exists and remove it from application directory if exists.
Then paste following code in .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I assume you already perform the other steps which includes turn on the rewrite engine in WAMP and in config.php
$config['index_page'] = 'index.php';
to
$config['index_page'] = '';
Also set
$config['uri_protocol'] = 'REQUEST_URI';
I hope it helps.
I have tried a lot to remove index.php from the url .
Its not working at all.
In config.php
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Then put this below code in .htaccess of my project root.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [PT,L]
I have tried ,its throwing page not found errors only.
Any suggestion ??
Thank you
Your base URL is not the base domain name, so modify your .htaccess file and add the following:
RewriteBase /cloud
This should fix your issues.
You need to change config.php and .htaccess file.
Changes in application/config/config.php
$config['index_page'] = ""; // And Remove index.php
Changes in .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Make Sure
Your .htaccess must under cloud directory.
Rewrite module must be enabled in Apache.
try this ,
Changes in .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Make sure your RewriteEngine is on in apache conf file if not then follow this link
How to enable mod_rewrite for Apache 2.2
I am using codeigniter v3 for my website and I'm having problems redirecting from one page to another.
If I click the tab, the link shows localhost:8080/IDS/view/decisiontree and shows Object not found! The requested URL was not found on this server...
If I edit the URL and make it localhost:8080/IDS/index.php/view/decisiontree, the site perfectly loads.
Here are my routes:
$route['view/decisiontree'] = 'data_controller/goto_decisiontree';
Here are the codes of the tab related:
<li>Decision Tree</li>
Here is my data_controller:
public function goto_decisiontree(){
$data['page'] = "2";
$this->load->view('decisiontree_page', $data);
}
And here is my config.php:
$config['base_url'] = 'http://localhost:8080/IDS';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Here's my .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
And note, I'm using Codeigniter V3.
Thanks a lot for the help!
Try the following
Open config.php and do following replaces
$config['index_page'] = "index.php"
to
$config['index_page'] = ""
In some cases the default setting for uri_protocol does not work properly. Just replace
$config['uri_protocol'] ="AUTO"
by
$config['uri_protocol'] = "REQUEST_URI"
HTACCESS
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Hope it helps .
Try this htaccess in main directory of your codeIgniter project. It seems to work fine in xampp and wamp.
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
config.php
$config['base_url'] = 'http://localhost:8080/IDS/';
$config['index_page'] = "";
$config['uri_protocol'] = 'REQUEST_URI';
All ways remember that you should have first letter of file name and class as upper case the rest lower case. refer
More htaccess examples here
Note: I'm on Ubuntu, so the paths here may change if you are on another distro.
I tried all .htaccess suggestions and none seemed to work, so I started thinking that was not the problem. And then it hit me, the apache.conf file. Doesn't matter the .htaccess you have, if that file is restricting the override, there's nothing you can do.
So i went to /etc/apache2/ and edited the apache2.conf file adding this:
<Directory /var/www/html/your-project-folder>
AllowOverride All
Require all granted
</Directory>
Also change $config['index_page'] = index; to $config['index_page'] = ''; in application/config/config.php as said above.
Btw, my .htaccess looks like this:
RewriteEngine On
RewriteRule ^(application) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
And don't forget to restart apache.
Please try to set the index_page blank in config.php file
$config['index_page']= "";
Also please change the .htaccess file:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Try below in your .htaccess file
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase /
# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)
# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|assets|css|js|images)
# No rewriting
RewriteRule ^(.*)$ - [PT,L]
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
For more detail, you can visit here
Hi I am a newbie at codeigniter.
When i access the url name "http://abc/php/newseller/home/sign" it is giving 404 error. But when i access http://abc/php/newseller/index.php/home/sign then it will give the page. I want to remove "index.php" and my site should run with this url "http://localhost/php/newseller/home/sign"
For this i tried in .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
And also remove index.php in application/config/config.php
$config['index_page'] = '';
but getting the same problem of 404
you can try to change also this method in config.php
$config['uri_protocol'] = 'AUTO';
Change the setting in the config.php file
$config['index_page'] = 'index.php';
$config['index_page'] = '';
please remove an index.php file and the set the base URL it will work fine.
please try this htaccess code.
RewriteEngine On
RewriteBase /Project Folder Name
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|scripts|styles|vendor|robots\.txt)
#RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
I want to remove index.php from code igniter URL ,I had created .htaccess file and stored it in application folder parallel to index.php and also remove
$config['index_page'] = '';
from config.php.
Code in .htaccess file, which is not working :
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /WCPM/index.php/$1 [L]
URL of the project is:
localhost/WCPM/index.php
NOTE:Please Don't mark this question as duplicate because I had already tried lots of solution for the same but none of them works for me , so at last I am asking this question here for the solution
In Config.php Change as Follows
$config['index_page'] = '';
$config['base_url'] = 'http://localhost/WCPM/';
And Create .htaccess file like
RewriteEngine on
RewriteCond $1 !^(index\.php|[WCPM])
RewriteRule ^(.*)$ /WCPM/index.php/$1 [L]
and Save this in Root Folder [WCPM] i.e. near Application Folder.
For More Details Refer the CI Manual # http://ellislab.com/codeigniter/user-guide/general/urls.html
Enable mod_rewrite module in apache.
If that doesnt work or mod_rewrite is already enabled, try this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
First of all, change following setting in your config file.
$config['index_page'] = '';
and then, replace .htaccess file located at your project root folder not in the application folder with the following code..
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
There is a full article for this at:
http://www.web-and-development.com/codeigniter-remove-index-php-minimize-url/#remove-index-php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|imgs)
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^media/imatges/([0-9]+)/([A-Za-z0-9-]+).jpg?$ imgs/$1 [T=image/jpeg,L]
<Files "index.php">
AcceptPathInfo On
</Files>
This is the entire recommended code to put at the start of your .htaccess file