azahar azahar - 1 year ago 69
SQL Question

Need to change the routes on every route used in an app but don't want use to find/replace

I'm working on modifying a web-app.I am not part of the original development team (the ones who made the app), it was just donated to us.

For bureaucracy reasons we cannot make a virtual host on the server (the server is an Ubuntu server (v15.*) using apache2) and bind the subdomain (specially because we don't own the server on which the app runs).
For that reason we need to make the app run on a folder within the webroot folder (/var/www in this case).

The problem is this:

Completely and abosolutly all routes used in the app's code where made assuming it would be put directly in the webroot directory
For example:

include 'includes/header.phhp';
include_once 'includes/encode.php';

That in php. It also involves html sources like:

<link rel='icon' href="imagenes/favicon.png" type="image/png" />

And inside javascript code:

url: '/js/reservas/src/php/wizardsubmit.php',

As expected the server will try to find the resources within the root directory like so: (using the html image source shown above) and it will fail to do so, because there is an intermediate directory (the app directory in the webroot) so the correct address to find the resource would be:

As you can imagine by the title, I don't want to depend on finding and replacing each of the routes in the code because it's huge (even using linux facilities like grep and sed) and would take me forever.

Is there a way to solve this programmatically, like using a php callback to the server to append the complete route?

It may be not clear, but the developers didn't create and much less use a "$this->basePath" variable, so I can't depend on that because in the same way I would have to write it all over the code.

Answer Source

Using a <base> tag in page would help for browser to know which directory to make relative requests to

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download