CodeIgniter links not working in localserver - codeigniter

I have a copy of PHP project running using CodeIgniter framework. It's hosted in some server and when I am trying to access a particular URL
www.xxxdomain.com/member/member/index
The above URL is loading a page with CSS
it I call the same link in the below manner still the page is loading but it couldn't load CSS
www.xxxdomain.com/member/index.php/member/index
now, when I download this code and trying to run in my own localserver when I am trying to call as http://localhost/project1/member/member/index I am getting an 404 error at the same time when I call it as http://localhost/project1/member/index.php/member/index the desired page is loading but loading without CSS.
How come the page load with the same URL in my server and not running in my localhost?? I changed the base_url setting and I am pretty high sure that I replaced all instances with the localhost url instead of server url but still the issue persists.
Any idea how to fix this?

create a file .htaccess in your root CI folder in you localserver...
and paste this Rewrite code..
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
if you want to read more about htaccess..
make sure u leave your config index_page blank....$config['index_page'] = "";

Related

I want to block assets folder path in Codeigniter

Am new in Codeigniter i want to block assets folder in my website. I mean website users(website viewer) enter http://www.example.com/assets it move to 404 page.
Please help me...!
Thanks in advance
If your assets folder is there to serve things like CSS, JavaScript and image files (like would be intended), and is an actual directory, then you can either do this by adding a .htaccess file to the directory (assuming it's running under Apache) which will take all requests which are not for explicit file paths and route them to the website controller/action for a 404 (or other page you use for this).
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ http://yourdomain.com/path/to/404 [QSA,L]
</IfModule>
Alternatively, you can add an index.php file which redirects the browser to the location for a 404 page, or displays a 404 type page as a response.
header("Location: http://yourdomain.com/path/to/404");

Getting default (not CI) 404 for all pages

I am trying to develop using CI for the first time. I have not changed any defaults WRT paths, .htaccess, etc. Two hours ago I was able to load pages; now I am not. All of this is on a virtual box running on my Mac, and I had been messing with the virtualbox settings in order to try to get the web pages to load while connected to a VPN (did not succeed). At no time did I edit any files on the VM, whether for connect settings or related to CI and my project.
Giving up with the VPN, I returned to my project to continue with code enhancements. Only now, as my title suggests, nothing will load. The default "It works" page loads so I know nginx is responding to requests. I don't get the Code Igniter 404 page -- I get the generic:
Not Found
The requested URL /index.php/c_login/ was not found on this server.
In this example, c_login extends CI_Controller and displays a view in its index function.
Based on my searches:
My config.php contains $config['uri_protocol'] = 'REQUEST_URI';
There was no .htaccess file previously, and that is still the case
I don't understand the bit about capital first letter in my controllers, as I've had lower case since I started the project and had no problem
Except for a minor change to a view file (not trying to load that one right now), nothing has changed since the last pull from the git server
I had left the welcome_message view and welcome controller in place when starting this project, and that no longer works either. Any ideas? I am at a complete loss.
Change this
In your config.php
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
then in .htaccess(this should be place out side of application folder)
RewriteEngine on
Options -Indexes
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
EDIT 01
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Migrating a CodeIgniter site to a different domain and moving the whole thing down one level in directory

I am working on a site, which is built with CodeIgniter.
I have never used the framework before...I've learnt a little bit in the last couple days but really cannot solve my problem.
I have downloaded the site and I want to upload it to my own domain so not to make changes to the live site before testing.
the original site is example.com.
I want to upload it to mysites.com/examplesite (this will be the base - I use this domain for all my clients' test sites).
I have moved all the files and the database is in place.
I have found the database configuration file and have successfully edited it.
I am having trouble getting the site to work, I think it must be because of the site now being down a directory level.
I have edited $config['base_url'] so that it is correct...I am pretty sure it is correct because I can now reach the homepage where I couldn't before editing that variable. But, i can only reach the homepage - when I click on a link to another page, I get 500 error Internal server error.
Does anyone have a quick fix for me?
Thanks!
Keep this code on your project's root .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /examplesite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Joomla not finding index.php after

I had turned Use URL rewriting to ON
Added some code in to the ht access file and this never worked.
I then turned off url rewriting and removed the code and now when I try to go to the website I am getting a 404 error.
I can still access /administration
the website is www2.daxtra.com
the page it should find is http://www2.daxtra.com/index.php/home
Does anyone have any ideas what has happened?
This was the code I added:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
Thanks
Right, I've done a small test.
To get what you want, you need to following:
htaccess.txt (you don't need a .htaccess file)
Search Engine Friendly URLs set to On
Use URL rewriting set to Off
You finally need to ensure that your Homepage menu items it set to a specific component such as an article or something else, not an Alias
This will ensure that you get example.com/index.php/home
Hope this helps

codeigniter in subfolder

I made a backoffice module using codeigniter for one of our websites and I've put it into a folder called backoffice. The website itself does not use any framework, its just a couple of static websites, some of them reading some data from database. It does not have any .htaccess file or any routing.
When I try to access the backoffice it does not work. The error log says it is trying to get my default controller from outside of the subfoler:
File does not exist: /usr/local/apache/htdocs/home, referer: http://64.91.226.165/~captainj/backoffice/
What can I do, did you meet this kind of problem so far?
Thanks
AS YOU CAN SEE I AM ACCESSING THE DOMAIN THROUGH IP ADDRESS AS THE DNS IS NOT SET YET
UPDATE:
I just found out that this is happening only when I try to access the module through IP address. I have copied it on another server and accessed by domain name and it works. But I still need to get this work using IP address.
try removing the url bad part with htaccess removing also index.php:
RewriteEngine On
RewriteBase /~captainj/backoffice/index.php/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

Resources