Trying to hide the index.html from the browser bar

I tried removing the index.html from the browser bar without any luck with this in my .htaccess

RewriteEngine On
RewriteCond %{THE_REQUEST} /index.html [NC]
RewriteRule ^index.html$ / [L,R=301]

RewriteCond %{REQUEST_URI} ^/index.html$ [NC]
RewriteRule ^index.html$ / [R=301,L]

and i wanted to ask if there is a limitation from infinityfree to prevent this from happening

Rewrite rules work on our hosting like they work anywhere else.

That said, just having these lines should do the trick:

RewriteEngine On
RewriteRule ^index.html$ / [R=301,L]

No need to have any extra RewriteCond line if you just want to match a specific URL unconditionally I think.

4 Likes

It’s not working

Can you please be a little bit more specific about what’s not working? What do you expect the code to do and what do you actually see?

Also, it would help a lot if you could share the URL of your website so we can see and test things for ourselves.

I’m fairly confident my .htaccess rules do the thing the rules in your first post are supposed to do, but I have the suspicion that those rules don’t actually do what you would like them to do.

4 Likes

smartdoors.rf.gd I expect it when I go in Specific pages to hide the /index.html this just makes it /index

For me, your site does hide index.html from the URL and shows the root URL.

2 Likes

Thank you for showing your website URL. Because there are some very interesting things in there.

For starters, you should know that the file index.html is a default directory index. That means that if you try to open a page, say, http://example.com/about/, the server will return the content from the index.html in the about directory. No need to specifically include index.html in the URL.

Right now, your account menu has a URL like ../garazoportes/index.html in it, which browsers understand as https://smartdoors.rf.gd/garazoportes/index.html. But if you just go to https://smartdoors.rf.gd/garazoportes/, you’ll see the exact same page. Completely out of the box, no .htaccess required.

So I think the solution of your issue is not to do URL rewriting with .htaccess rules. All you need I think is to make sure that your website’s HTML code doesn’t have links to the full files anymore and just link to the directory and you’re done.

That said, I’m not sure I can tell you what would be the best way to do it. The code of your website itself suggests that it’s running on WordPress, but it’s actually just HTML code. Is the WordPress site running somewhere else and using some kind of WordPress-to-HTML converter? If so, that plugin may have an option to configure how URLs are rendered in the website.

6 Likes

I am doing changes in the website and I need to enter incognito mode to see the new changes do you know why?

Incognito mode bypasses all caches, so it could be used for development without having to worry about your browser caching your website. As to why your changes don’t show up on your normal window, but on incognito mode they do, please clear the browser cache by pressing a few times Ctrl + F5 while viewing your website.
If that doesn’t help (because some browsers are stubborn) then follow these instructions:

6 Likes

Can I put in to my website to not save caches?

Or every time someone goes in to clear the website cache?

We don’t cache anything on the server, all the server does is tell the browser to cache data.

You can override these cache headers using .htaccess rules. However, while caching can be annoying during development, please understand that they exist for a reason, and disabling them will lead to a slower website and higher account resource usage. So I’m not going to look them up for you, because I do not recommend using them.

4 Likes

when i do some changes in the website how can the users see the change?

I don’t think you have to do anything and that WP does it by itself

WordPress can handle cache clearing automatically, but it often depends on the caching plugin you’re using. Many popular caching plugins, like WP Rocket , WP Fastest Cache , and W3 Total Cache , offer automatic cache-clearing options. These plugins can be configured to clear the cache whenever you update a page, post, or theme.

Here are some examples of how it is on your site and what techniques are used:

prevent caching

Versioning: Add a query string to your CSS and JavaScript files, like style.css?v=1.1. When you update the file, change the version number (v=1.2), forcing the browser to load the new file.

image

5 Likes

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