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
Related
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.
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/
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
I was in the need of migrating my site to a subfolder, it is a php script, its links are like this :
aff_link.php?id=812 (number changes at the end)
and html files like
gifts.html
rss_feeds.html
and others ending in .html
I need to redirect those two kind of links to a subfolder called "old"
any advice on this?
Thank you in advance.
You can use this rule in site root .htaccess:
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)q=id=\d+ [NC]
RewriteRule ^aff_link\.php$ /old/$0 [L,NC,R=301,NE]
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.