Error while running codeigniter php project - codeigniter

I am working in php project using codeigniter. I am very new to codeigniter. I have exiting project that i managed to run properly.But when i am inserting username and password,its
giving me error as=
"The requested URL /PRS/index.php/login was not found on this server."
I am using wamp server. httpd.conf file has documentRoot as "c:/wamp/www/PRS/"
My .htaccess file has code as-
RewriteEngine On
RewriteBase /PRS
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /PRS/index.php/$1 [L]
My project's config.php file has code as-
$BASE_URL = "http://".$_SERVER['SERVER_NAME']."/PRS/" ;
$DB_HOST = "localhost";
$DB_USER = "root";
$DB_PASSWORD = "mysql";
$DB_NAME = "prsdb";
So can someone please help me..

At first make sure mod_rewrite is enabled in httpd.conf file and after that, overwrite your .htaccess file which is located your project root 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
And then set your base url like following..
$BASE_URL = "http://".$_SERVER['SERVER_NAME']."/PRS/";
And change your config file like following..
$config['index_page'] = '';
And finally use the following url to access..
prs.net/PRS/login
Or, you can check the following url to get some help..
Cannot remove index.php from CodeIgniter URL

Related

my codeigniter project is not accessing index.php after my project folder name

my codeigniter project is not accessing index.php after my project folder name
..
http://localhost/projectName/(here index.php is missing)/controllerName/FunctionName
I removed index.php using .htaccess file. But when i inspect source code of navigation bar there were missing index.php in url (eg. ब्यूटी).
It is working on localhost but in the live server not working.
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php/$1 [L,QSA]
i tried but not working

The requested URL was not found on this server' in XAMPP; Used Answers in Other Threads

I am using the latest version of CodeIgniter and XAMPP. I have searched stackoverflow and followed te suggestion from other threads with the same problem, to no avail.
I have several CI projects running oin my localhost b(each with their own CI install). I recently started a new project and went through the following steps to remove index.php from appearing in the URL:
Changed $config['index_page'] = "index.php" to
$config['index_page'] = '' in config.php
Changed $config['uri_protocol'] = "AUTO" to
$config['uri_protocol'] = "REQUEST_URI" in config.php.
Updated the .htaccess file to the following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Restarted apache
Yet I am still getting this error.
I have confirmed that mod_rewrite is installed in my XAMPP config. Plus, I am using rewrite rules for the other projects on my locolhost and they are working fine. I also made sure that update the base_url in the config: $config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/folder_name';
I have tried variations on the .htaccess file that I have found in other answers, yet an still at a loss. I've done this before; what's different!?
EDIT: I am only getting this error when trying to explicitly go to a controller/method. I have the default controller set to my login controller, so going to http://localhost/folder_name correctly hits the Login/login() controller/method. However, if I change the url to go to http://localhost/folder_name/login/login, I get the 404 error. However, http://localhost/folder_name/index.php/login/login/ eorks just fine still.
I my self use XAMPP. and windows 10
Inside your project folder place the htaccess
htdocs > folder_name
htdocs > folder_name > .htaccess
Here is one I use
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]
Then on the config.php
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
$config['base_url'] = 'http://localhost/folder_name/';
$config['index_page'] = '';
Some case you will need to make sure you have the class and filename set where only the first letter is upper case. Explained here naming classes and here filenames
Add RewriteBase with your project folder name.
Change your .htaccess to
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project_folder_name
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

how to configure codeigniter hmvc in subdomain

H,
I'm using codeigniter hmvc framework.i don't know how to configure this fo subdomain. i've installed it but not working. any help please.
project/
application/
controller/installer
modules/
default controller is pointed to installer.php
$route[default_controller] = 'installer';
but unable access the controller.
No matter it is hosted in subdomain or main domain. You need to do couple of things to make it workable.
Step one
Config base_url in config.php as follows:
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
Step two Check your .htaccess. It should looks like as bellows:
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 vary depending on server. In some server (e.g.: Godaddy) need to use the following .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 will help you.
find this file
application/config/config.php
edit here thats all
$config['base_url'] = "http://subdomain.example.com/";

error while uploading codeigniter 3 on godaddy .only the default controller is working

I am using codeigniter version 3. It's working absolutely fine in localhost, but when I am trying to upload this to godaddy server ,only default controller is working. Please anyone suggest the necessary configuration changes. I tried changing the .htaccess file but not working.
Working configuration on my godaddy server.
.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
routes.php
# Default
$route['default_controller'] = "home";
config.php
$config['base_url'] = '';
$config['index_page'] = '';
UPDATE:
1) base_url()
2) robots.txt
3) .htaccess

CodeIgniter Rewrite URL: remove index.php from url

My apps url is
http://localhost/myapp/admin/index.php/projects
and I want to rewrite it as
http://localhost/myapp/admin/projects
I followed user guide
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
for this but not work for me.
Please follow these steps:
1- If you work on localhost please enable mode_rewrite in php.ini
2- Create a .htaccess file under project folder and paste this (please change 'project' to your project folder name):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /project/index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /project/index.php
</IfModule>
3- Edit this line at application/config.php:
$config['index_page'] = "";
Thank /* ActuallyMAB */: Your code actually works. The above code works on localhost (WAMP Server on windows).
If you have placed your codeigniter project in some folder such as your directory structure looks like:
C:\wamp\www\proposal
So, You have to replace
RewriteRule ^(.*)$ /project/index.php/$1 [L]
to
RewriteRule ^(.*)$ /proposal{or your folder name}/index.php/$1 [L]
if this is not the case with your project {you have put your codeigniter directly into www folder}, then remove the folder name from the above code as it looks like;
RewriteRule ^(.*)$ /index.php/$1 [L]
also do not forget to change
$config['index_page'] = 'index.php';
to
$config['index_page'] = '';
in your config folder {config.php}
I hope others have also provided the same answer, but since the above code works in my project and i felt to provide some details too.

Resources