0

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

Sridhar
  • 11,466
  • 5
  • 39
  • 43
vijju
  • 462
  • 9
  • 30

3 Answers3

2

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

ZZA
  • 727
  • 6
  • 6
2

"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

Faris Mohamed
  • 73
  • 1
  • 5
1

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.

Brad
  • 159,648
  • 54
  • 349
  • 530
  • Is there another method to remove .html file from url – vijju Jul 24 '18 at 04:00
  • @vijju Read the first paragraph again where I explain to you why it's not possible without a web server and ask any clarifying questions you have. – Brad Jul 24 '18 at 04:03
  • I am using cloud functions as sever and firebase is the database for my website. so I hosted my website into firebase . While hosting the firebase creates a public folder in that .html files are stored. so I placed the .htaccess file in that folder – vijju Jul 24 '18 at 04:13