Why do I get an error when trying to acces my html page?

So my website https://www.example.com works perfectly fine. But when i try opening another page, for example: https://www.example.com/p/tools the URL changes to this: https://www.example.com/public_html/tools and gives me an “404 Not Found” Error with the description saying: “Check if the URL is correct and remember it is case-sensitive.”

How do i solve this?

My .htacces file is down below

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

RewriteRule ^p/(.*)/?$ $1 [NC,R=301,L]

RewriteCond %{THE_REQUEST} /([^.]+).html [NC]
RewriteRule ^ /%1 [NC,L,R]

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
</IfModule>

I don’t have the full knowledge of how the .htaccess file works, and even got this from another user that helped me remove the .html from the URL when entering different pages.

Answer

Try this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
</IfModule>
  • Please note: for EVERY Test in your browser don’t forget to clear the browser-cache.

Leave a Reply

Your email address will not be published. Required fields are marked *