oupala / apaxy

a simple, customisable theme for your apache directory listing
https://oupala.github.io/apaxy/
GNU General Public License v3.0
1.86k stars 256 forks source link

Server name being stripped from URL for sub directories #80

Closed jasonculligan closed 6 years ago

jasonculligan commented 7 years ago

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

duncanplatt commented 7 years ago

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.

AdamWhitcroft commented 7 years ago

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

oupala commented 7 years ago

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

ijavid commented 7 years ago

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

PHR16384 commented 7 years ago

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).

oupala commented 7 years ago

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?

Perritu commented 7 years ago

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).

oupala commented 7 years ago

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/

PHR16384 commented 7 years ago
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.

carlos-jenkins commented 6 years ago

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

carlos-jenkins commented 6 years ago

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

Now working on both Chrome and Firefox.

duncanplatt commented 6 years ago

I am glad to hear, @carlos-jenkins!

oupala commented 6 years ago

Can we close this issue?

oupala commented 6 years ago

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