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]
Related
I tried to remove index.php from my url in codeigniter i tried by creating with .htaccess file but it does not works.
RewriteEngine on
RewriteBase /
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
I tried by using this code and also these are mu bse and site url.I not have much knowledge that how to use htaccess properly.Any help is appreciable.
$config['base_url'] = 'http://localhost/xxxx/';
$config['site_url'] = 'http://localhost/xxxx/index.php';
Open config.php and do following replaces
From:
$config['index_page'] = "index.php";
To:
$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";
Add in .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]
Hope this will help you :
Options +FollowSymlinks -Indexes
RewriteEngine on
DirectoryIndex index.php
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
and also set your config.php:
$config['index_page'] = '';
$config['base_url'] = 'http://localhost/foldername/';
for more : https://www.codeigniter.com/user_guide/general/urls.html
Try the below code to remove index.php from url, Make an htaccess file in the root folder and paste the below code in it.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
For remove index.php in the url you need to change the configuration.
Change the following in your config.php file
$config['index_page'] = "index.php";
TO
$config['index_page'] = "";
This will remove index.php from url.
If it helps anyone here, this problem drove me crazy and the solution for me was removing the capital letters from the project folder (it was originally localhost/working/CourseIgnite/).
so after many attempts at the problem I changed site to localhost/working/courseignite/
Then using the solutions that everyone posts worked. Mod rewrite on, change base url and index in the config, and used the below in the htaccess.
Just hope this helps as it was driving me bonkers.
RewriteEngine on
RewriteBase /working/courseignite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Then in application/config
$config['index_page'] = "index.php";
TO
$config['index_page'] = "";
and also in application/config
$config['base_url'] = "yourlocalhostip/working/courseignite/";
I want to create a app url 'http://example.com'. But entering the url, it shows 'HTTP Error 403.14 - Forbidden'. when i have inserted 'index.php' at the last of url like 'http://example.com/index.php' the landing page is rendering in the browser
I have changed the
$config['base_url'] = 'http://example.com';
$config['index_page'] = '';
and
$config['uri_protocol'] = 'REQUEST_URI';
in config.php file. Then i have placed the .htaccess file in the codeigniter root folder along with application and system folder. Then in the .htaccess file i have coded with
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I just want to remove the 'index.php' from the url. I am using IIS 8.5 web server.
htaccess file
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
my site is working http://demo.crowdfundingscript.com/
config file
$config['uri_protocol'] = 'AUTO';
$config['index_page'] = '';
Replace this line:-
$config['uri_protocol'] = 'REQUEST_URI';
to
$config['uri_protocol'] = 'AUTO';
also change your base url as below.
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/';
Write your rules as below:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
Hope it will work for you :)
In config.php,
remove index.php in $config['index_page']
For ex :
$config['index_page'] = '';
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
Removing the index.php from URLs have caused my form pages to not receive POST data.
This form is on the URL http://localhost/guestbook/
The following form tag works:
<form method="post" action="http://localhost/index.php/guestbook/">
This (and leaving it blank) does not work:
<form method="post" action="http://localhost/guestbook/">
The first one does work fine, but it changes the URL the user sees to the action url - I would like to keep the index.php out of the URL.
This is my htaccess.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1/ [L]
How could I get the form to submit to the rewritten URL?
in config file change it
$config['index_page'] = 'index.php';
to this
$config['index_page'] = '';
may be work fine
Try this may help
Htaccess file will be :
<ifmodule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</ifmodule>
And make changes in Confg file application/config.php
Make $config Blank
$config['index_page'] = '';
Open config.php and do following replaces
$config['index_page'] = "index.php"
to
$config['index_page'] = ""
Just replace
$config['uri_protocol'] ="AUTO"
to
$config['uri_protocol'] = "REQUEST_URI"
AND IN HTACCESS FILE put 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]
Okay so I know that a lot of people have been asking the same or similar questions, but I don't seem to find a solution that works for my project. So please don't put this as a duplicate.
I have a website made with codeigniter. It was running just fine without the index.php in the url. So the rewrite was successfull. Until a few days ago: all of a sudden the admin area (/admin) returned a 404 and was only accessible by the path '/index.php/admin'. The rewrite code that once used to work didn't do a thing anymore.
And know I'm back at the start -> the problem is that I cannot delete the index.php from my url.
I tried so many things that I don't know what to do anymore.
The application is stored under 'public_html/application/...
The image below is inside the application folder where the .htaccess file and index.php are.
Is this the right location to change the .htaccess?
I tried rewriting the .htaccess but without success:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^CI/(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots|css\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
My config file:
$config['base_url'] = 'http://www.mysite.be/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
Routes.php:
$route['default_controller'] = "c_home/index";
$route['404_override'] = '';
$route['admin'] = "c_home/adminpanel";
$route['logout'] = "c_login/logout";
Does anybody have a clue what is going on or how this can be fixed?
Thanks in advance!
The .htaccess should be in the public_html directory -- ie: one level up from the current location.
The index.php is presumably in public_html already and
The index.* you have in the picture is index.html -- as it should be.
If .htaccess is in the right place per the above, then this .htaccess code will work:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
So I have been messing around with this and finally made it work
For this I made changes to the htaccess and controllers.
I changed the admin function to a new controller and changed this in the routes.php
new routing
$route['admin'] = "c_login/index";
new .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Try set
$config['uri_protocol'] = 'PATH_INFO'
And set
$config['enable_query_strings'] = FALSE;
If we need a remove /index.php from url in codeigniter
Than
application/config/config.php
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
add .htaccess file at root directory of project
RewriteEngine on
RewriteBase /[Your project folder name]/
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Now you can access like
http://example.com/controller/method
May it's helpfull for you
I don't know what the heck you're doing with all that code, but I just put this in my .htaccess file:
RewriteRule ^(.*)$ /index.php?/$1 [L]
And boom.