vijju
vijju

Reputation: 462

How to remove .html extension from the url

I want to remove the .html extension from the url.

eg file:///Users/DivyaGalla/Downloads/deyaPaywebsitee/public/index.html after removing I want is ./index only.

I am using cloud functions as server and firebase is the database. I hosted my website using firebase hosting.

When hosting the website it creates a folder that is public folder. It contains all the .html extension file.How to remove .html file extension from url. I wrongly used .htaccess for removing but it is not correct way.

So please any one can suggest me the correct way to remove the url

Upvotes: 0

Views: 9493

Answers (3)

Faris Mohamed
Faris Mohamed

Reputation: 73

"cleanUrls": true

The cleanUrls setting is an optional parameter that, when true, will automatically drop the .html extension from uploaded file URLs. If a .html extension is added, a 301 redirect will be performed to the same path without the .html extension

Upvotes: 2

ZZA
ZZA

Reputation: 767

U can use like this.

RewriteEngine on
RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]

and name as .htaccess in your root path

Upvotes: 2

Brad
Brad

Reputation: 163301

When loading HTML files from disk (such as with your file: path), there is no web server in between the file and the browser. With no web server, there is nothing to interpret rewrite rules, and thus this is not possible.

Once you do host your content with a web server, you should know that .htaccess is just a config file naming convention for Apache HTTPD. Ideally, you configure your server somewhere else, as Apache will have to parse that file every time something is loaded in that directory otherwise. This is highly inefficient.

Upvotes: 1

Related Questions