Wrong URL in 1.4.7

I ran the upgrade procedure: unzipped the contents of the v1.4.7 (and copied database.php from old installation to application/config directory). I tried to run https://mysite/setup but it redirects to https://mysite/path/to/invoiceplane/index.php/language

It seems it wants to initiate the setup with the language choice, but instead of a url it places the serverpath in the url. Is this a bug?

No I don’t think so. InvoicePlane now tries to automatically set the domain and subfolder of your installation.
I tested this with the following URLs with both http and https:

http://localhost
http://localhost/invoiceplane
http://localhost/subfolder/invoiceplane
http://ip-test.com
http://ip-test.com/invoiceplane
http://ip-test.com/subfolder/invoiceplane
http://subdomain.ip-test.com
http://subdomain.ip-test.com/invoiceplane
http://subdomain.ip-test.com/subfolder/invoiceplane

and all URLs were set correctly and I could access the setup without problems.


To prevent the automatic URL detection, replace

$config['base_url'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . ($_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']) . URL_SUBFOLDER;

with

$config['base_url'] = '';

in application/config/config.php.

I tested the above (empty string) but that didn’t work. It changed my url to https://[my-local-ip-address]/index.php/setup/language

So I changed $config[‘base_url’] = “https://my.domain/” and it worked

*edit: I changed it to the following: this will even be better (remove " . URL_SUBFOLDER"):

$config['base_url'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . ($_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']) . URL_SUBFOLDER;

Changed to this:

$config['base_url'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . ($_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']);

I have a similar case: I have installed InvoicePlane in the directory invoiceplane-v147, and created a symlink to invoiceplane. My hosting provider’s Apache config is such that I can then access these folders as subdomains: http://invoiceplane.mydomain.com and http://invoiceplane-v147.mydomain.com.

The code describe above (in application/config/config.php) messes up in my situation. When going to http://invoiceplane.mydomain.com it tries to load files from http://invoiceplane.mydomain.com-v147. So for some reason stuff after invoiceplane gets inserted after the domain name (this is true also if I have a _ instead of -, or in fact anything else).

Removing . URL_SUBFOLDER as per @Laurens’ suggestion fixes this.

Hi all. Firts I must say that I truly appreciate Invoice Plane and I was sorry to read that it may become obsolete in the future, although I understand Kovah’s situation perfectly.
This being said, I had the same problem as you @Laurens with the last update and I solved the problem by typing directly the address as you suggested. I’d like to apply your “edit” though, but my address includes a subfloder (“https://my.domain/myfolder/”) and I just don’t know how to modify the string to include it. A little help here would be appreciated! :wink:

Hi @Gef, try this:

$config['base_url'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . ($_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']) . '/myfolder/';

notice the extra myfolder addition at the end. I’m not sure if this will work, I haven’t tested it, but you could try and report back. :wink: Good luck.

It works indeed. Thanks Laurens!

1 Like

I had similar issue on Windows machine. Had to comment the following line in index.php

//define(‘URL_SUBFOLDER’, ($_SERVER[‘DOCUMENT_ROOT’] != dirname(FILE) ? str_replace($_SERVER[‘DOCUMENT_ROOT’], ‘’, dirname(FILE)) : ‘’));

and replace it with
define(‘URL_SUBFOLDER’, ‘’);

This was on Apache

Today I tried IIS on windows 10 and again I had to comment the same line as in my previous comment. I created a virtual directory on IIS but the new line changed to

define(‘URL_SUBFOLDER’, ‘/[virtualDirectoryName]’);

I thought my problems solved but in fact I cannot save anymore and there’s also a bug when i transfert a quote to an invoice. Finally, I regret to have performed this last update. Is there a way to go backwards?

Not sure how to go back except by using backups. (you do make backups, don’t you? ;))

I would suggest to check out any logfiles related to apache, mysql/mariadb, php etc… before you look for a rollback. It might be something else entirely.

Hi, I just reinstalled the whole thing and problems are now solved. I have access to this app through my web hosting service so that I don’t have a choice on the version installed. Thanks for all anyway.
I have other questions now but they’ll go in a new topic!

I suggest waiting until sunday. I’m already preparing the update package.

OK, will do. The issue I have is that if you add a payment to an invoice it automatically converts the status to paid, which may not be the case if you just wanted to add to the invoice a previous down-payment or deposit. And if the paid status forbids further changes, then you’re stuck! Precisely what happened to me, while I had not finished to fill the invoice form. By the way, if there’s a way to delete a locked invoice entry, I’ll take it :blush:

The new version is out so please try again.

Invoice deletion can be enabled if you want. You can find more information about this in the wiki: https://wiki.invoiceplane.com/en/1.0/modules/invoices#delete

Finally!!! Thanks guys because this is really the solution!!

Same problem here. Just made my first installation in a root folder of a vhost. Visiting “https://invoicing.example.com/setup” redirects to “https://invoicing.example.com/www/htdocs/accountname/InvoicePlane/setup/language” which is the internal path to the PHP files but does not work of course.

Changing $config[‘base_url’] to the subdomain I wanted to use solved my problem

I would like to know how these problems can be solved in a more suitable way?

One possible solution: the user has to set the preferred domain in the config file before running the setup. What do you all think?

I added a separate bug report for that:
https://development.invoiceplane.com/browse/IP-450