URL for Folder view not working - it redirects to 404 after showing files.

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
So i have tried to generate URL for few folders (public and private) in the file manager and i open that link, it shows the files in that folder which is great but then it redirects the URL to 404 page..
Any ideas ??
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
Found a bit of info on this:
Right now my 404 is set as
if (!$file)
{
//coreFunctions::eek:utput404();
coreFunctions::redirect(coreFunctions::getCoreSitePath() . "/404." . SITE_CONFIG_PAGE_EXTENSION);
}

If i uncomment the first line, then it works fine but the problem is i get a blank page when there is a 404 error which i dont want. i want to show a 404 page.

Has anyone else seen this issue ?
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
Adam, any suggestions on how i can have my 404 page and still view folders using URL ?

Basically what its doing is, i will open a URL for the public folder and i see the webpage for about a second and then it redirects to 404 error page. I dont know why (!file) function is getting executed....
 

adam

Administrator
Staff member
Dec 5, 2009
2,046
108
63
Which format urls are these? Like this:

https://fhscript.com/folder/17/Documents

Maybe some screens or a video would help understand the issue?
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
Adam, Thanks for looking into this. I have sent you a PM on this forum with a link to the video.
Whats shown in the video is what happens when i have this 404 page line in the code.
Code:
if (!$file)
{
//coreFunctions::output404();
coreFunctions::redirect(coreFunctions::getCoreSitePath() . "/404." . SITE_CONFIG_PAGE_EXTENSION);
}
If i remove the 404.html code line and only have "coreFunctions::eek:utput404();" in the code, the folder view works fine and it does not redirect me to 404 which is good but the problem is when there is an actual 404, it shows me a blank page which i dont want, i want the users to see a 404 page in case of real error.
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
okay nevermind, you have your PM disabled so i submitted a ticket via your contact page. It has the link to the video asp er your request..
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
Hello Adam,
Can we have this looked at please?
I believe the 404 code is checking for no file exist. (!$file). If there a way to add a OR command in this line to check for Folders as well ? I want to have this ability to share folders on my site but i am unable to do so.
 

adam

Administrator
Staff member
Dec 5, 2009
2,046
108
63
I believe I looked at this before but I was unable to reproduce it in our dev. Are you able to see it on the demo site?
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
Adam, yes you did look into that.
If you give me FTP access to your demo, i can reproduce it.

All i changed was in case of 404 error, show a 404.html page instead of blank page and the folder URLs started redirecting to 404.html page.

If you want to make that change in your dev site and try it out ?
What i figured is that you have if (!$file) then show 404. This will need to be changed so there is a OR statement that if a user is viewing a folder, dont redirect unless there is no such folder available.

For your 404 on folders, you have the script to redirect to homepage instead of 404 or blank page..
 

adam

Administrator
Staff member
Dec 5, 2009
2,046
108
63
Can you remind me the the urls, was it these type:

https://fhscript.com/folder/17/Documents

I'm confused as these don't have if (!$file)... in them. I assume that was changed on the file_download.php file?
 

adam

Administrator
Staff member
Dec 5, 2009
2,046
108
63
If you can post a sample failing url I'll try to debug it, although it's caused by a change in the script which isn't really tested during the normal release process.
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
yes, the URLs are of this type and the 404 error page change was made in file_download.php

and i believe i have a fix for it now, so what i did was i created another if statement in the !file to check if the URL had the word folder in it and if it did, to not redirect to 404 page and that seems to be working....

The only thing left is to redirect users to 404 if folder doesnt exist. This still redirects them to homepage instead of 404 page.