Codeigniter website not working on live server page not found - php

I have uploaded my website on 000webhost server in vegshop folder, my link is "http://sp16bcs034.000webhostapp.com/vegshop/", however there is error 404 page not found
and my .htaccess file code is:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1
!^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

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]
Note: .htaccess code vary depending on hosting server. In some hosting server need to use an extra ? in the last line of above code. The following line will be replaced with last line in applicable case:
// Replace last .htaccess line with this line
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

Try this htaccess file, you have uploaded code in the subfolder.
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteRule ^$ /vegshop/index.php [L]
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /vegshop/index.php/$1 [L,QSA]
Or sometimes time you have to replace the last line in above code with this as per server
RewriteRule ^(.*)$ /vegshop/index.php?/$1 [L,QSA]

Place below .htaccess file in vegshop folder
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /vegshop
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<ifmodule !mod_rewrite.c>
ErrorDocument 404 /index.php
</ifmodule>
In application/config/config.php set as below
$config['base_url'] = 'http://sp16bcs034.000webhostapp.com/vegshop/';

Related

Removing index.php in Codeigniter 3 apache2 server

I am working on Code Igniter in Kali Linux, I have configured .htaccess file as mentioned in Documentation and configured file correctly but its not working without index.php
a2enmod rewrite
I have also enabled rewrite mode and restarted apache. Here is my .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
in config.php
$config['uri_protocol'] = 'REQUEST_URI';
$config['index_page'] = '';
create .htaccess file with the following at your project's loctation
(for eg: /var/www/html/yourproject create .htaccess inside 'yourproject' folder )
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
add the below to your virtual host configuration file
<Directory "/var/www/html/yourproject">
Options All
AllowOverride All
Allow from all
</Directorey>
then restart apache
Follow this steps to remove index.php from url
1)Remove "index.php" from config.php file
$config['index_page'] = "";
2) Your .htaccess file should be:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
3)Some cases you also have to change this in config file
//find the below code
$config['uri_protocol'] = "AUTO"
//replace with the below code
$config['uri_protocol'] = "REQUEST_URI"
Simply use this in your .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

How to remove index.php from URL in CodeIgniter using .htaccess

I know this question is asked many times before and I've gone through most of them already but couldn't find a solution. I've tried most of the answers given here, here and in CodeIgniter official documentation. And restarted apache each time. It didn't work for me. mod_rewrite is already enabled in my apache server.
Weird thing is, I've a working example for WAMP (in my laptop):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /project/index.php
</IfModule>
It works perfectly in WAMP, but it doesn't work in LAMP. Any kind of help is appreciated.
Please use below code:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
I have used this and it is working.
Try Below code in your .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ROOT DIRECTORY NAME/
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<Directory "/path/to/document/root/">
AllowOverride All
Allow from All
</Directory>
Just like this......
.htaccess inyour root directory with following code..
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Set configuration in application/config.php as follows..
$config['base_url'] = 'http://domain_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
I made it working with the help of following .htaccess code:
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
And I updated <Directory /var/www/> section of /etc/apache2/apache2.conf file with:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
It solved all problems and now it works fine.
here it is my approach:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
And also in config.php replaces
$config['index_page'] = "index.php"
to
$config['index_page'] = ""
and also in the same file replace
$config['uri_protocol'] ="AUTO"
by
$config['uri_protocol'] = "REQUEST_URI"

How to skip index.php in URL rewriting?

I have set WAMP up and running without too much hassle. But thing is I could not skip past index.php in my URL (localhost/index.php/login is working but localhost/login is not working).
Anyway my project is based on CI framework and I was using vagrant previously for hosting same project and which is working perfectly for this case. I have checked that the rewrite_module on for Apache and here it is my .htaccess file.
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Please help me out from here.
First of all go in your project myproject-application->config.php
replace line no. 29
From
$config['index_page'] = 'index.php';
To
$config['index_page'] = '';
Then add .htaccess file on your root folder.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Try this .htaccess file code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

codeigniter removing index.php from 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
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /public_html/
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>
and in WAMP apache (ver.: 2.4.9) 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..
Use this htacess and then go to config.php and remove index.php
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]

Removing index.php of codeigniter on local

I'm trying to remove index.php,in my localhost, but it seems doesn't working,its on http://localhost/testing.
I put .htacces in 'testing' directory under the htdocs.
LoadModule rewrite_module modules/mod_rewrite.so
at Apache/conf also already unchecked.
Here my .htaccess:
RewriteEngine On
RewriteBase /testing/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /testing/index.php/$1 [L]
Here my config:
$config['base_url'] = "http://localhost/testing";
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
When I access login controller, it's not found.
Not Found
The requested URL /testing/login was not found on this server.
I really don't know what to try next. Any help would be appreciated.
Try this :-
Config.php :-
$config['base_url'] = 'http://localhost/testing/';
$config['index_page'] = '';
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Your htaccess should be like
RewriteEngine On
RewriteBase /testing/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
There's no need to append /testing/ since RewriteBase already takes care of that.
basically the index.php is included in all URLs:
we can remove this using .htaccess with a simple rules. following is an example of such a file, using the "negative" method in which everything is redirected,
RewriteEngine on
RewriteBase /testing/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
now restart your server and check
Leave out the trailing slash in RewriteBase:
RewriteEngine On
RewriteBase /testing
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
$config['base_url'] should be http://localhost/testing/
$config['index_page'] should be blank.
Try this one in the .htaccess file:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|resources)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
ErrorDocument 404 /mainpage
your config file is fine
Difference being the "?" after index.php
You may also want to try changing the value of $config[‘uri_protocol’] in ./application/config/config.php. Sometimes CodeIgniter gets it wrong. Changing it to PATH_INFOmight work.

Categories