Index.html works from htdocs but not in sub folder

Hi, I have index.html in two places, htdocs and a subfolder. my https://website path works but when i access https://mywebsite/subfolder/ I do not see my index file. If I enter https://mywebsite/subfolder/index then it works. I do not want to be required to type in index each time.

On another webserver I have this in my virtual host,
Alias /subfolder/ “C:/path to htdocs/htdocs/subfolder/”
accessing the subfolder without typing index works here

I tried to put This alias Directive in htaccess but not working
please advise, thanks

Welcome.

We can’t help you if you don’t provide your websites URL.

Please make sure to fill out the template next time!

5 Likes

website url is https://cookiefreecoders.com/Java
getting 403 forbidden error
but if i type https://cookiefreecoders.com/Java/index , I do get the correct index page for the sub folder.
I dont want to have to type in index each time

my location is epiz_32679036

Can you please share your htaccess file that you modified, and any other htaccess files on the site that are relevent?

Thanks!

3 Likes

some things i tried are commented out
below is htaccess file contents

Alias /Java/ "/Java/"
#DirectoryIndex Java/index.html
   #enable suppression of html extension 9-28
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

#RewriteEngine On
#RewriteCond %{REQUEST_URI} !^/Java
#RewriteRule ^(.*)$ Java/$1

#RewriteEngine On
 #RewriteBase /Java/
 #RewriteRule ^$ login [L]

I believe you can comment out everything in your .htaccess.
The default setting on free hosting should load from index.php or index.html
The “alias” seems redundant as well.

In fact, it is causing what you want

to not to work in the first place.

Remember to clear browser cache after editing .htaccess to see the updated changes.

2 Likes

I tried to access the https://cookiefreecoders.com/Java URL but got the 403 error. Then I renamed the .htaccess file to something else and tried opening the page again, but then it did work.

So I think the Alias rule you set up is causing the issue. I’m not sure what you were hoping to achieve by making /Java/ an alias of /Java/. I would expect that making something an alias of itself would do nothing in the best circumstances and otherwise it breaks stuff. And it seems like the latter has happened.

3 Likes

Thanks for helping. What I am trying to accomplish is to have the sub folder index page appear when mylink/Java/ is clicked, without users having to type mylink/Java/index.html. I want to be able to give out a link to the home page of a sub folder. I need sub sections of my website to have their own index pages. When people give out links to their website they do not include the index.html in the link, it is the default to the site. My sub folder needs to be the default to its own area. At present my subfolder index works but only when I type in index.html. For my home page, index.html is implicit (the default). Also, please note the trailing slash after the link. Without this I get error 403.

You mentioned that renaming htaccess made it work. Please tell me what u did and the logic behind it, thanks

Thanks but I really don’t understand ur response

They do, you don’t need an htaccess file for that, it already works.

What admin did is basically tell the system to ignore the htaccess file, and pretend like it does not exist.

You need the trailing slash because you are accessing a folder, not a file

3 Likes

Thanks very much ALL for the responses but I cleared my cache and re tried https://cookiefreecoders.com/Java/ and I still get 403 error. Also I tried in both chrome and firefox. I do not see any changes in my htaccess file nor do i see a renamed htaccess file

Probably because admin changed it back.

Delete the htaccess file, clear your cache, and try again.

1 Like

thanks, this solution did work but now without an htaccess file my other directives do not work. I don’t mean to be a pest but what to do next? thanks

What other directories? Do you have an other random htaccess files placed somewhere that could be messing it up? Is there an index file in those directories?

1 Like

I said directives not directories. Without an htaccess file how would i make other directives work when I need to implement them?

You can have a .htaccess file and put whatever directives in it you want.

The problem was that you put all kinds of rules in it to make it so that opening the /Java URL loads the /Java/index.html file. But that’s already the default behavior, and the rules you added broke this behavior.

Having a .htaccess file is not what broke your website. Having bad rules in your .htaccess file is what caused the issue.

3 Likes

Thanks and I appreciate this response which makes sense, but I created new htaccess file and added a directive which does work but now path to /Java/ is broken again and giving me 403

Since the only thing that changed is that you added a directive, then the directive must be the problem. Remove it and it will work fine again.

If you want help, let us know what you are trying to accomplish

3 Likes

ok thanks, I commented out the directive and things are working again.

I want to be able to access files without having to type in .html so below is my directive and it does work but breaks my other issue. Am I doing this correctly?

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]