Help with moving codeigniter to a new server - php

I am having a bit of a problem. I am duplicating my website to a test environment on a new server with a new domain.
I have it working fine with the database etc but here is my error.
On the live site if I click suppliers it goes to the page fine If I click it on the test environment it does not work.
These are two links
http://wvtest.co.uk/
http://theweddingvine.com/
The code to create the link is as follows:
<?php
echo anchor('search', 'Suppliers');
?>
The file and the folders are the same. Is there something in codeigniter which can direct the link ?

Modify application/config/config.php and set:
$config['base_url'] = "http://{$_SERVER['HTTP_HOST']}/";
That will make your links work on either server.

have you specified the correct base_path for your testing server in application/config/config.php file?
Check that please, this is the case mostly in such problems.

You could change your base_url to
$config['base_url'] = 'http://wvtest.co.uk/';
or
$config['base_url'] = '/';

Related

CodeIgniter 3 base_url function returns wrong url

I am using XAMPP, MySQL and CodeIgniter.
I already included,
$autoload['helper'] = array('url');
in autoload.php.
<?php echo base_url(); ?>
returns http://::1/mysite/ instead of http://localhost/mysite/.
Can anyone help me with this issue?
You need to make sure you have set your base_url in. Most likely because you left it blank. This is a common thing that people do not know about or forget to do.
application > config > config.php
$config['base_url'] = 'http://localhost/mysite/';
One of the issues when you try to submit form with out base url not set is will not go to correct url, when you try to submit a form so that why in codeigniter 3 all ways best to set your base_url even though not a requirement.
Also here are some htaccess for codeigniter xampp & wamp
Htaccess For Codeigniter

Unusual base url in Codeigniter with Chrome

I found it is unusual with the latest stable version of CI (3.03),
I tried echo base_url() and it returns some unusual thing,
**Note: ** I have loaded the URL helper .
The following code
$this->load->helper('url');
echo base_url();
returns http://127.0.0.1/ (I have used http://localhost/ to interpret the application) in Firefox.
And:
http://::1/ (Same I have used http://localhost/ ) in Chrome ?
Help me guys in fixing this.
Please remove base_url form the config file if you set there,
$config['base_url'] = "http://".$_SERVER['HTTP_HOST']."/";
In your config, use define. like below:
define('base_url', 'http://localhost/your_project name/');
And then try
echo base_url() ;
Make sure you have set a base url
$config['base_url'] = 'http://localhost/project/';
Some times for me that is issue.
In older versions of CI you use to be able to leave that blank but.
Now it is recommended that you do not leave that base_url blank.
And I would auto load the url helper as it is the most common one.

CS CART -Wrong css path

I am new in cs cart.
I have done the following steps
1.downloaded a cs-cart-V3 website to my localhost.
2.Change database setting,and import database.
3.$config['http_host'] = 'localhost'; added in **config.local.php** file.
4.Removed .htaccess file from root folder.
My problem is
The site was loaded,But the path of css is wrong.It is trying to load from localhost Not from localhost/subfolder,
Where i need to change this?
Please check config.local.php
Mainly the following lines:
// Host and directory where software is installed on no-secure server
$config['http_host'] = '';
$config['http_path'] = '';
Please make sure that the store-front URL is also correct. It can be checked:
In the cscart_companies table in the database (storefront and secure_storefront columns)
On the Administration -> Stores page (Storefront URL and Secure storefront URL fields)
At the end, do not forget to clear cache. You can do it by adding the "?cc&ctpl" to the URL in the admin panel. E.g.
http://your_domain.com/your_admin.php?cc&ctpl

Joomla 2.5.9 Domain name repeating in URL

I have installed the Joomla 2.5.9 on Windows server with IIS7 . :)
I disabled all the SEF setting in configuration.
Now , I logged in to admin of joomla 2.5.9. When I see the public side , it show it perfect.. but when I go for any other link.. it have multiple time of domain name in url..
like...
http://domainname.com/index.php?option=com_content&view=article&id=6&Itemid=102
I tried with enabling SEO URL , and enabled the web.conf. and settings like below,
Search Engine Friendly URLs -yes
Use URL rewriting -yes
Adds Suffix to URL -yes.
http://domainname.com/domainname.com/features.html
is this error with joomla 2.5.9???
Thanks,
Gaurish
http://forum.joomla.org/viewtopic.php?f=615&t=820080
Change in configuration.php
var $live_site = '';
to
var $live_site = 'http://domainname.com';
I tested with some configuration & that works for me..
I tried JTC code,
public $live_site = 'http://domainname.com';
It works on front-end, but throws the error in backend , even I am not able to Login in admin.
So, I changed the configuration file as below,
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (true== strpos(strtolower($url),'administrator')) :
class JConfig {
.......
public $live_site = '';
......
}
else:
class JConfig {
......
public $live_site = 'http://www.domainname.com/';
.....
}
endif;
and this work perfectly for me.. all the URL's on front-end are showing correct, not domain name repeated.
But URL's in back are showing same as early, but I can do the updates & admin task there.. that really don't interrupt me.
One more think , I am not able update global configuration file.. as we edited it .. so I need do it manually.
Thanks,
Gaurish

links not working on web server

i have developed a php application which is running perfect on local server. when i deployed the application on web server the links are not working
1) my site is "abc.myapplication.com" (abc is subdomain)
i defined following variable in config file
define('ROOT_PATH', $_SERVER['DOCUMENT_ROOT']);
ROOT_PATH variable shows /home/punjabfo/public_html/abc (which is perfect)
for link i used following code
Add Record
link should go to "abc.myapplication.com/addrecord.php" but link go to
"abc.myapplication.com/home/punjabfo/public_html/abcaddrecord.php"
i tried a lot but could not fin the issue. please help. thanks
What is wrong with Keeping It Simple
Add Record
Let the server do all the work, as it gets it right and you do less messing around.
Try
define('ROOT_PATH', $_SERVER['HTTP_HOST']);
Just use
Add Record
You can try -
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo 'http://'.parse_url($url, PHP_URL_HOST) . '/';
Your issue is "$_SERVER['DOCUMENT_ROOT']". $_SERVER['DOCUMENT_ROOT'] stands for the root directory on the server (dir-path). What you need, is the URL and not the file-system-path.
Take a look on
<?php
echo "<pre>";
var_dump($_SERVER);
echo "</pre>";
?>
Why not to do
Add Record
Of course you do not need ROOT_PATH in the URL. What you do is returning full path of the file, instead of link. And btw, full path is incorrect itself, as you forgot slash before addrecord.php.

Categories