Fearless Mode
Fearless Mode

Reputation: 241

How to force loading extension ".html"after a url via .htaccess?

How could I achieve this?

force load extension via .htaccess ".html" after a url?

Pretty simple, but I couldn't find something a stack article on this or something similar to tweak accordingly.

If someone visits Domain.com/about I want them to land on Domain.com/about.html

Simply put I want to force all url's to load .html after the url via .htaccess.

This is to cover visitors, etc. with old links that don't have .html at the end of the url.

Upvotes: 0

Views: 464

Answers (2)

anubhava
anubhava

Reputation: 785128

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+?)/?$ $1.html [L]

Upvotes: 1

DFayet
DFayet

Reputation: 881

Does this page helps you: https://www.garron.me/en/bits/add-html-extension-nginx-apache-htaccess.html

Or take a look here, you can find a bunch of propositions.

Upvotes: 1

Related Questions