0

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: http:address.com/imagenes/favicon.png (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: http:address.com/appdirectory/imagenes/favicon.png.

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.

azahar
  • 48
  • 7
  • 1
    Using a `` tag in page would help for browser to know which directory – charlietfl Jun 01 '16 at 22:28
  • I didn't know the `` tag. I will use it, however this requires the directory name, so I can only use 1 name (and cannot be changed). Is there a way to make this directory name dynamic? – azahar Jun 01 '16 at 22:41
  • Depends what you mean by dynamic. Could wrap some php around it and set it on server based on some app criteria – charlietfl Jun 01 '16 at 22:43
  • I found this [similar issue](http://stackoverflow.com/questions/20308395/how-to-dynamically-set-the-base-tag). I'll try using javascript as they did. Can you write an answer to this question so I can mark it or should I do it? – azahar Jun 01 '16 at 22:57

1 Answers1

0

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

charlietfl
  • 170,828
  • 13
  • 121
  • 150