A
A
Alexey Smirnov2014-03-13 16:42:34
URL Handling
Alexey Smirnov, 2014-03-13 16:42:34

How to remove .html at the end of the address of each web page of the site, without using php?

I have read that it is possible to remove .html using .htaccess file, but all the code I have seen for removing .html is written in php.

And since I use free hosting and it has a ban on using php, I can't remove .html.
Is it possible to somehow remove the file extension at the end of the address without using php?
Java script like...

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey Shirokov, 2014-03-13
@ERAFY

RewriteEngine On
RewriteCond %{REQUEST_URI} ! \.html$
RewriteCond %{REQUEST_URI} ! /$
RewriteRule ^(.*)$ $1.html

in htaccess. A call to /about will open /about.html, for example

V
Viktor Naymayer, 2016-11-30
@viktornaymayer

Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
Explanation:
#Turn on the conversion mechanism
RewriteEngine On
#Set the condition "the file path is specified in url?"
RewriteCond %{REQUEST_FILENAME} !-f #If
yes, then just remove html
RewriteRule ^([^\.]+)$ $1.html [NC,L]
PS Now we specify the path in the code like this: <a href="example">Example</a>
And of course, instead of $1.html, you can write $1.php

P
platinum11, 2015-02-06
@platinum11

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^.*$ $0.php [L,QSA]
RewriteCond %{THE_REQUEST} ([^\s]* )\.php(\?[^\s]*)?
RewriteRule (.*) %1 [R=301,L]
for those who need to remove the php extension from the url (address bar). code tested and working

I
Ivan Pogorelov, 2014-03-13
@Ipogorelov

Folder with the name and in it index.htm

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question