Removing index.php in Codeigniter HMVC - codeigniter

I am tried to remove index.php in Codeigniter HMVC. But I Could not complete with the following code.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I placed .htaccess file in root directory and removed index.php from config file. Still I'm facing the same problem.

in your config.php file put
$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";
Then in .htaccess file put
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
Now, check your url removing index.php. It will work.

Please follow some step:
goto application/config/config.php :
replace $config['index_page'] = 'index.php'; to $config['index_page'] = '';
and
$config['uri_protocol'] = 'REQUEST_URI'; to $config['uri_protocol'] = 'AUTO';
enable rewrite mode by
sudo a2enmod rewrite
then
service apache2 restart
if you'd like, you can use the following .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Simply create one new file .htaccess.
And past it the below code into the .htaccess file.
Then go into the project folder follow the path application->config->config.php
into the config.php file
$config['index_page]='index.php'; replace to $config['index_page'] = '';
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example/index.php/$1 [L]
// into the above line example is the project name, you have to replace the example to your project name

RewriteBase /g-pos /// Your htdocs
RewriteEngine On
Options -Indexes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Related

Can't remove index.php from URL

I am trying to remove index.php from URL, but I keep getting error 404.
Config file:
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
This is my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
You need one more .htaccess file in your application folder, and here is the detail of the file:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|captcha|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Please copy and paste following code in your htaccess file and put it in root folder and application folder
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [L]
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]

removing index.php in hmvc

i want to removing index.php in hmvc code igniter , when i type the url without index.php it's running well but when i process to other controller the url is automatically showing index.php after my codeigniter folder.
example i type :
localhost/ci_hmvc/user/login
and the result when i process to other controller is :
localhost/ci_hmvc/index.php/user/dashboard
and my .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /ci_hmvc/index.php/$1 [L]
</IfModule>
please any one help me
You can make changes in config.php which is in config folder
You can see the line
$config['index_page'] = 'index.php';
Change this line in to
$config['index_page'] = '';
I hope this will helps you
put this code in .htaccess and place the htaccess file to the root of the folder..
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]

Remove index.php from Codeigniter URL in Wamp

I have big problem trying to remove index.php from url's
i have searched lots if forums (this also), but no help for my situation.
so i have config.php file
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
my .htaccess file in public_html folder near index.php.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
i have rewrite_module ON (and it's working) and my httpd.conf AllowOverride set to All
so when i am going to mydomain.com/controller/action - I get 404
but when i go to mydomain.com/index.php/controller/action - everything is OK..
i have tried lots of .htaccess examples... and so on.. nothing helps..
.htaccess (This should be place outside application folder)
Paste this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Note : Sometime index.php will not remove in windows. But if you upload it to server it will work fine. This happen me too in XAMPP but if i upload it to host(Linux) it works fine
My Config which is working fine :
config.php
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
.htaccess
# index file can be index.php, home.php, default.php etc.
DirectoryIndex index.php
# Rewrite engine
RewriteEngine On
# condition with escaping special chars
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

Remove index.php from URL in CI?

I removed index.php from the URL in CodeIgniter. I have already changed the .htaccess file data. But I want to know that is there any other way to remove the index.php from the URL or through any other .htaccess data. Means this is only a way or not.
In .htaccess file I wrote this :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Try This code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
and do not forget to null index value in config file
$config['index_page'] = '';
Try this :
Make sure you have enabled rewrite_module on your Apache modules
.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|indexcp\.php?|resources|robots\.txt)
RewriteRule ^([A-Za-z0-9_/.-]+)$ index.php?/welcome/$1
Open config.php :-
$config['index_page'] = '';
$config['base_url'] = 'http://www.example.com/'; //your site name
$config['uri_protocol']= 'REQUEST_URI';
Options +FollowSymLinks
RewriteEngine on
# Send request via index.php (again, not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

after removing index.php from url in codeigniter

My login Controller : $this->load->view('login-view');
My link that redirects to 'login-view' is in the template is: anchor('login','Login');
Before removing index.php from url in codeigniter works well. But after removing index.php from url it is not working.
My .htaccess file is :
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
hard to expalin i think, Thats all i have got. :(
Try this in .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
And in config.php
$config['uri_protocol'] = 'AUTO';
Just remove index.php from your config file.
$config['index_page'] = "index.php";
should be
$config['index_page'] = "";

Resources