简体   繁体   中英

How do I reconfigure a CodeIgniter site taken from an online Linux server to work on a localhost server

The website was originally on a Linux server and I was given a copy of the site and the .sql database.

I began by trying to reconfigure it for XAMPP.

In CodeIgniter I changed the database.php file to have the correct hostname, username, password, and database. Then I changed the base_url to the localhost root url for the site.

This caused the css to show correctly for the login page so that it looked just as it did online. However when I tried to login with the same username and password, which I had used online, it redirected me to the http://localhost/xampp/ instead of the homepage for the site.

When I typed in an incorrect username or password it gave an error message, but when I typed the correct user name and password it redirected me to the XAMPP page, which implies that the database connections are working.

I tried the same type of thing with an ubuntu virtual machine server and it didn't even recognize the base_url to correctly show the css.

What would be causing the site to redirect to the XAMPP page and how can I reconfigure it to allow me to log in to the home page? Do I have to create an entirely new site and transfer all the code and files into it piecemeal? If this is the case what would I need to leave out?

I pursued the suggestion about the .htaccess file, but instead of getting the file from the live server I just used the following code in the .htaccess file and changed the .htaccess file in the application folder to the default statement for CI.

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /base_name_of_site/
# If your project is in server root then should be: RewriteBase /
# If project is in folder then it should be: RewriteBase /folder_name/

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>

The login now works and I can now access and edit the entire site on the local server. Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM