Herf page showing as directory listing

Website URL

https://www.artscollections.space/fantasy
https://www.artscollections.space/vector/

Error Message

Directory Listing

Other Information

when I open other pages other than the index page of my website it gives me a “Directory Listing” of the page instead of the actual webpage.

Hi, in order to be able to see a webpage instead of directory listing, you need to have a file named either index.php or index.html in those folders.
Could be because those files went missing during upload process?

9 Likes

Screenshot 2023-07-26 164556
I have tested the code on other hosting platforms and everything is working fine there, There is no file missing it or any broken code that could affect the issue. all html files are in the root directory and .CSS and ,js are in one folder, as you can see in screenshot

You did not show what is inside fantasy and vector folders.

3 Likes

lol seriously, as I said before it’s all media files in there.


If you don’t want people to show the Directory Listing on where you have files other than your website’s index files stored, you can either create an empty index.html or index.htm file or you can put this in a .htaccess you have to create on every folder:

# Disable directory listing
Options -Indexes

If you want to get fancy, you can also redirect people to your HTML pages for fantasy and vector with PHP by creating an index.php file instead of an empty HTML one on the folders with this content:

<?php
   // this is for the fantasy folder; replace it with vector.html when you create it on the vector folder
   header("Location: /fantasy.html");
   exit;
?>
6 Likes

I will try PHP, I’m not good at PHP, so I have to see how to do it.
I have created index.php in both folders “fantasy” and “vector” with content contant

In “fantasy” folder

<?php // this is for the fantasy folder; replace it with vector.html when you create it on the vector folder header("Location: /fantasy.html"); exit; ?>

“vector”

<?php // this is for the fantasy folder; replace it with vector.html when you create it on the vector folder header("Location: /vector.html"); exit; ?>
1 Like

After adding index.php to both the folders the page is not even accessible!

OK, I can see the problem now. You’re trying to make vector.html and fantasy.html accessible without extension, but the redirects collapse causing an error “Too many redirects”. Try to add this to the main .htaccess file of your website and remove the other lines that do the redirect to the non-HTML version:

Options +MultiViews

Like so your website will be accessible through both non-HTML and HTML extension at the end. Then you can remove the index.php on the folders as that isn’t needed and remove the / before a folder’s name to see the HTML page content.

I was already using using

“Options +Multiviews”

Now I have changed it with

Now the whole website is crashed. :skull:
https://errors.infinityfree.net/errors/403/

Options MultiViews
RewriteEngine On

Remove “index.html” from the URL

RewriteCond %{THE_REQUEST} /index.html [NC]
RewriteRule ^(.*?)index.html$ /$1 [L,R=301,NC]

Redirect URLs with “.html” extension to extensionless URLs

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+).html$ /$1 [R=301,L]

Add .html extension internally

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^([^.]+)$ $1.html [L]

Yeah, I intended to say Option +MultiViews. Add a + before MultiViews and remove these lines:

RewriteEngine On

# Remove "index.html" from the URL

RewriteCond %{THE_REQUEST} /index.html [NC]
RewriteRule ^(.*?)index.html$ /$1 [L,R=301,NC]

# Redirect URLs with ".html" extension to extensionless URLs

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+).html$ /$1 [R=301,L]

# Add .html extension internally

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^([^.]+)$ $1.html [L]
1 Like

Can you please tell me what exactly should I remove?

I have already removed: “Option MultiViews” and using “Option +MultiViews”
If there is anything else that needs to remove then please give me the whole .htaccess code that needs to use. because after removing “Option +MultiViews” and “Option MultiViews”, the issue is still the same.

On your .htaccess there will only be Options +MultiViews.

1 Like

But it will expose

.html

at the end of each urls. I want to hide them that’s why I have created .htaccess at first, place!

Cannot you just rename the vector.html and fantasy.html to index.html and move them to their appropriate folders?

e.g vector.html ->vector/vector.html and rename to index.html?

6 Likes

Thank you so much, I should listen to you earlier

but why infinityfree has to do all these things, when I was using another web hosting with the same file director it was working there but not on Infinityfree!

Afaik it is like this with most of web hosting providers, last time I saw /filename.html become /filename was cloudflare pages.

6 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.