Operating System & Version
macos mojave
cPanel & WHM Version
88

Abs Zaa

Registered
Dec 9, 2020
2
0
1
Dubai
cPanel Access Level
Website Owner
In the public_html folder I have 2 files:
home.html
test.html

home.html links to test.html with:
<a href="https://mysite.com/test.html">Test</a>

I do not want to display the .html extension in the browser.
My htaccess file is as follows, but the .html extension is still displayed:

# BEGIN GD-SSL
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_USER_AGENT} ^(.+)$
RewriteCond %{SERVER_NAME} ^education\.mekan\-turk\.com$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Header add Strict-Transport-Security "max-age=300"
</IfModule>
# END GD-SSL


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,028
313
cPanel Access Level
Root Administrator
Hey there,

I had good luck with this block of code inside an existing Wordpress site:

Code:
#Redirect /filename.php to /file
RewriteCond %{THE_REQUEST} \s/([^.]+)\.php [NC]
RewriteRule ^ /%1 [NE,L,R]
#Internally map /filename to /filename.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)/?$ /$1.php  [L]
Can you try that?
 

Abs Zaa

Registered
Dec 9, 2020
2
0
1
Dubai
cPanel Access Level
Website Owner
Thank you but your code is for php. I am looking for .html.
The following code works on Chrome for me, but not on Safari or Firefox.

Code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
</IfModule>
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,028
313
cPanel Access Level
Root Administrator
I also confirmed that isn't working for me in Firefox when I tested just now.

I don't have any additional code snippets to provide, although I am surprised that modifying the PHP version I provided also doesn't seem to work for html files. Perhaps another community member will add some of their thoughts here to help.