Linking to a php site located in a subdirectory of the Drupal site So I've taken part in a very interesting Drupal project that has a multilingual Drupal 7 site and three sub-sites (all using the same domain) in sub-directories of the main Drupal site. So it's kind of like this:

http://example.com &lt;- main Drupal site
http://example.com/site1 &lt;- php site that doesn't use Drupal
http://example.com/site2 &lt;- php site that doesn't use Drupal
http://example.com/site3 &lt;- php site that doesn't use Drupal


Now I can create relative links to these sites on the Drupal site by adding links like

&lt;a href="site1"&gt;Site 1&lt;/a&gt;


And that works when I'm on the homepage, but since this is a multilingual site, any other page I go on uses a language prefix on the URI like this:

http://example.com/en/contact


If I try to click on the Site 1 link I made above while on the contact page, it takes me to:

http://example.com/en/site1


and displays a 404 error.

Currently, the site uses hard-coded absolute links to get around this issue, but it's becoming a real pain to use this in our local and testing environments and I've been asked to remove the absolute urls from these links.

I've tried a few different things like using Token Filter with [site:url]/site1, but it still tries to add the language prefix and gives me the same 404 error. I thought of trying to use a module to look for these specific links and set them accordingly, but I can't think of an efficient way of doing it. Other ideas like using JavaScript to edit the links after the page loads or redirecting to the right page just smell so bad I don't want to try them.

Any ideas on how I can create links to these sub-directories without hard-coding them?
Well, I ended up going the JavaScript approach. I don't know how to get around using absolute links to the subsites without doing something pretty hacky, so I created a module that adds a javascript file when NOT in the production environment. The javascript searches all links for hrefs with the production domain and changes them to use the current page's domain.

Hence, in production the module does nothing, but in any other environment it replaces the absolute links.

Not optimal, but a workable solution for my case...