oupala/apaxy

Server name being stripped from URL for sub directories

Closed this issue · 14 comments

Apache2 on Ubuntu 16.04, /var/www/html contains the standard index.html location. I place .htaccess and theme in this folder and I can see the CSS styling works nicely. However there is a subfolder I use also in /var/www/html and when I hover over the subfolder icon 'http://servername/' gets stripped from the URL (http://servername/subfolder) and the URL just becomes 'subfolder' so I can't reach the subfolder. I can access the subfolder fine if I just manually enter 'http://servername/subfolder' myself. Also only happens with Chrome. Works fine with IE

Hi @jasonculligan, I've found this solution fixes it. I'm too new at git to submit a pull request, unfortunately, so I'm tagging @AdamWhitcroft for his attention.

I've narrowed the problem down to theme/footer.html on line 20:
Change this line:
while (i--){ var a = indexes[i].getElementsByTagName('a')[0]; a.href = '/' + uri + '/' + a.getAttribute('href',2); }

so that it matches:
while (i--){ var a = indexes[i].getElementsByTagName('a')[0]; a.href = '.' + uri + '/' + a.getAttribute('href',2); }

Notably, the a.href = '/' should change to a.href = '.'

You are now good to go.

Thanks for that @duncanplatt, pinging @oupala to verify.

I'm sorry to say that I don't have Chrome. I can't test the usecase.

I've faced the same problem on my enviroment, using a virtual host for public directoty listing link.
In root directory links are generated like //subfolder/ which is evaluated by browser (chrome) as a protocol-less hyperlink

I'm suggesting the following solution:
a.href = uri ? '/' : '' + uri + '/' + a.getAttribute('href',2);
this generates urls in root folder with one slash

Just letting you guys know that the above "fix" (via the js script appended to footer.html) causes the exact same problem when I test my server locally. "localhost:[port]" is stripped out and all my links are changed to "http://[subfolder_name]" and "http://[filename]".

Is this still an issue without that script on www hosted servers? If so, I'd suggest changing the fix to prepend all file/subfolder hrefs with the current URL (window.location.href), and prepend the "Parent Directory" link with the server IP (window.location.host).

I finally tested it with Chrome, and it appears that I can't reproduce the problem.

I'm using the develop branch, without further modification to any js.

Do you have any public instance of apaxy where I can test and try to reproduce the problem with my Chrome?

i've fund a possible origin of the problem.
Try to change all theme/ to /theme/ (but Apaxy should be installed on root directory, I think).

Ok. This problem has already been found, and fixed by a pull request (see #78).

This pull request has already been merged into branch develop. So try to install develop branch in order to check if it fixes your problem. And no, it does not mean you have to install apaxy in the root folder. Just edit the configuration to fit your needs:

/{FOLDERNAME}/theme/

  • Switching to the dev branch didn't help. Mostly because the .htaccess templates of each branch are identical (except for comments).
  • When viewing server subfolders (when I type them into the URL bar manually), links are fine; only screws up at server root dir
  • Should've mentioned: I've got my own special-snowflake way of organizing my server, Apaxy, etc. This is my directory structure:
C:/
+-- Dropbox/
|   +-- GitHub/
|   |   +-- AdamWhitcroft/
|   |   |   +-- apaxy-master/
|   |   |   +-- apaxy-master.zip
|   |   |   +-- batch-master.zip
|   |   ...
|   ...
|   +-- xampp-5.6.30/
|   +-- .htaccess

I've got a ton of repos archived, and Apaxy is one of them.
As a result, my .htaccess file looks like this:

...
AddIcon /GitHub/AdamWhitcroft/apaxy-master/apaxy/theme/icons/blank.png ^^BLANKICON^^
AddIcon /GitHub/AdamWhitcroft/apaxy-master/apaxy/theme/icons/folder.png ^^DIRECTORY^^
AddIcon /GitHub/AdamWhitcroft/apaxy-master/apaxy/theme/icons/folder-home.png ..
...

Once again, using window.location.href and window.location.host seems to fix the footer script on localhost; I'll try it on Google Cloud later today.

Hi I'm hitting this same issue with a current (master@af176b3932c01de23c32398c34eeb18e6f3b5b41) installation of Apaxy in the root of a virtualhost.

Happening with both Chrome and Firefox on Ubuntu 16.04 LTS.

Check image footer for link created by Apaxy:

screenshot from 2017-09-05 01-27-53

I can confirm that the solution provided by @duncanplatt works, thanks a lot!

Now working on both Chrome and Firefox.

I am glad to hear, @carlos-jenkins!

Can we close this issue?

Closing this issue as it is a duplicate of #100.