How to hidden name end url index.html - html

What I mean by last name in the url, like index.html for example the url link on my website homepage. the result is like this
https://hijaben.insomnia247.nl/index.html
I want to remove or delete the last name of the url (index.html)
I tried using the .htaccess file but it didn't work at all. Is it possible the script is wrong or the VPS doesn't support or what? the solution ..?
File .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html
</IfModule>

https://www.digitalocean.com/community/tutorials/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-16-04
Please check this out im sure it can help you with your problem sir.
https://www.linode.com/docs/web-servers/apache/how-to-set-up-htaccess-on-apache/

Don't overcomplicate things with unnecessary mod_rewrite. Just use DirectoryIndex index.html.

Related

Friendly url html with folder language

I was wondering how this site https://www.jrsa.com.ar/ works with friendly URLS and languaje selector.
For example, if you put https://www.jrsa.com.ar/es https://www.jrsa.com.ar/es/es is the same result, the same page. In the browser if you write https://www.jrsa.com.ar/servicios is the same if you write http://www.jrsa.com.ar/es/ex/servicios.
In the browser if you type www.jrsa.com.ar/folder/folder/folder/servicios is the same as www.jrsa.com.ar/servicios. I canĀ“t understand how you can add folders and getting the same page.
Can some help me to find to achieve this? I only have this htaccess
# Activar RewriteEngine
AddDefaultCharset UTF-8
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.html [NC,L]
RewriteRule ^([^\.]+)$ $1.html [NC,L]
Mi test URL is: http://clients.devilleartstudios.com/jrsa
Thank You
I suspect their content is stored in a CMS database that supports localized content. It is not feasible to do this with a manually-managed static website because you'll need to recreate common HTML structure (like navigation, global content, etc) in every page. If you really want to accomplish this with a static website then consider using a system like Jekyll: https://jekyllrb.com/

mod_rewrite to remove .html from address bar without changing links in the html file

First question. So I have a simple website "website.com" on Apache:
website.com
index.html
site1.html
site2.html
Within each html I have links to other, in this form:
main
site1
site2
I want the browser to display "website.com/site1" instead of "website.com/site1.html".
I've been playing with it for a few days and I always end up with one of these results:
Infinite loop of redirects.
Internal server error.
Both versions work (eg. "website.com/site1.html" and "website.com/site1") but the .html stays in the address bar.
I don't know what's going on. I can't even break it properly. For example I expected that this .htaccess will throw an error on accessing "website.com/site1", because there is no rule redirecting site1 to site1.html:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [R=302,QSA]
But no - it works, just doesn't delete .html in the address bar.
How Apache knows to redirect "website.com/site1" to "website.com/site1.html" without the proper RewriteRule for it? Is my understanding wrong, that I have to redirect from website.com/site1 to website.com/site1.html to make it work?
Thanks in advance.
The last line at your rules :
RewriteRule ^(.*)\.html$ /$1 [R=302,QSA]
It means to change any file.html to file only and what you need is to accpet file only the redirect it internally to file.html like this :
RewriteRule ^(.*)$ /$1.html [L,QSA]
But , in this case , the file.html will be as is so, if you want to remove .html at all try the folowing rules :
RewriteEngine on
RewriteCond %{THE_REQUEST} \s/+(.*)\.html[\s?/] [NC]
RewriteRule ^ /%1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ /$1.html [L]
The first two lines after RewriteEngine on will remove .html .
The rest of lines will check whthere the request withut extention is .html file or not , if it is accpeted .html it will be redirected but internally .
Now , both , site1.html or site1 will be site1 in browser.
By this , you will make sure that file accepet .html extention before redirecting and that will seperate this stage of being mixed with error files.

How to route from site.com/home to site.com/home.html (remove .html) in htaccess?

Many sites have URL addresses like this:
youtube.com/watch
Not youtube.com/watch.html.
For example, stack overflow now shows: https://stackoverflow.com/questions/ask, not https://stackoverflow.com/questions/ask.html or https://stackoverflow.com/questions/ask.php etc. How to do this in (simple site hosting) .htaccess (or another file, I only heard it was done in htaccess)
I think you should understand my question.
There are many posts about it already, but I couldn't find a one that fits my needs and works. Thanks.
To remove .html extension use:
#remove html file extension-e.g. https://example.com/file.html will
become https://example.com/file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
You should be able to read the above and figure out how to remove other extensions

Not having `.html` in Website URL?

How is it possible to have a url of a basic website, not include the .html at the end of a webpage?
My website is just a few pages, but I don't like having the .html in my link: www.mywebsite.com/mypage.html
If I type: www.mywebsite.com/mypage, of course, it's not found :(
I navigate around my site just using typical hyperlinks.
Probably a dumb question, but I've googled it and the stuff I find is way more complex than just html code and is usually referring to php or perl.
Thanks.
You sinply make an .htaccess file and put the following in it:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]
What web server software are you using? If Apache, you will likely be interested in the rewrite mod.
Something like the following:
RewriteRule ^mypage/?$ mypage.html [NC,L]
In your .htaccess file. I believe you need to enable the mod first too.
Simple solution is to change the name of your website from mypage.html to mypage

Rewrite a Specific URL with htaccess

Ok, So I am very noob with htaccess. Basically, I want my site
http://mydomain.com/game.html
to go to
http://mydomain.com/index.php?page=game
I don't have a current .htaccess because almost all I've tried, have failed.
Does anyone have a working one to that?
Try adding this to the htaccess file in your document root:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)\.html$ /index.php?page=$1 [L,QSA]
This internally rewrites a request for /anything.html to /index.php?page=anything. You'll have to make sure all of your links look like http://mydomain.com/anything.html though, because it doesn't do anything about what's shown in the browser's URL address bar.