B
B
Brendan Castaneda2021-06-17 12:36:44
URL Handling
Brendan Castaneda, 2021-06-17 12:36:44

How to remove html from URL?

There were many posts on this topic I read and tried but this helped me in part.
I clear the cached files each time so that Cloudflare will download a new version of those files from my web server. Also in the browser I reload the page with a new load Ctrl + Shift + R.

I added changes to the .htaccess
file . For example, if you write it down.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

The html extension is removed at the end of the url but mysite is added right after mysite.ru/, which messes everything up.
mysite.ru/ mysite /contact The
URL should look like this: mysite.ru/contact

In the html I specify the link like this If I add this code<a href="contact.html">Contact</a>

RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+)\.html\ HTTP
RewriteRule ^([^.]+)\.html$ <b>mysite.ru</b>/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule (.*) /$1.html

There is a similar story as with the first option.
If you remove the site name from the code, a similar situation occurs as before...
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+)\.html\ HTTP
RewriteRule ^([^.]+)\.html$ /$1 [R=301,L]
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule (.*) /$1.html

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Brendan Castaneda, 2021-06-17
@ae_ph

I found a solution to my problem!
I made the following entry in the .htaccess file

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

And in html I changed the entry to this Page index.html and contact.html I have in the main directory. <a href="contact">Contact</a>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question