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
website url is https://cookiefreecoders.com/Java
getting 403 forbidden error
but if i type cookiefreecoders.com , I do get the correct index page for the sub folder.
I dont want to have to type in index each time
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.
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.
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 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
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?
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.
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
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]