How can I remove the .html from the end of URL pages - html

I want to remove the .html extensions from the end of the file names. As seen on the website: tekmillion.com
Any help will be appreciated, thanks.

Use this to remove extensions in your .htaccess.
An .htaccess file is a simple ASCII file that you create with a text
editor like Notepad or TextMate. It provides a way to make
configuration changes on a per-directory basis.
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /html/(.*).html\ HTTP/
RewriteRule .* http://localhost/html/%1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /html/(.*)\ HTTP/
RewriteRule .* %1.html [L]
Checkout this reference to learn more about this.

there is a way but it is not really good. You need to change the extension of your files from .html to .php and than you need to upload them to online hosting or you need XAMPP server.
Note: If you try to run files with .php extension the browser won't load them except if you have XAMPP server.

change the name of the files to index.html and put them in separate folders
http://tekmillion.com/videos.html
should become
http://tekmillion.com/videos/index.html
and you can acees it using the link
http://tekmillion.com/videos/
and you will not see the .html

Related

how to remove the url extension

I am developing a website for myself, pure and without server language.
The urls are as they are called in the a tag, for example: blog / index.html.
Is there anything I can use to change that? I don't want to have to use framework. I would like to know if there is any tool that does this.
What I want to change is the ending. I don't want the extension to appear, just the route
try create .htaccess file on your root folder then paste this
#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 can read more about this here https://www.plothost.com/kb/how-to-remove-php-html-extensions-with-htaccess/
EDIT
Since you are using Vercel.com, as per their documentation there's a file config named vercel.json you can add this
{
"cleanUrls": true
}
the docs said,
When set to true, all HTML files and Serverless Functions will have their extension removed. When visiting a path that ends with the extension, a 308 response will redirect the client to the extensionless path.
for more information pls read their docs here https://vercel.com/docs/configuration#project/clean-urls

How to change example.com/blog.html to example.com/blog

www.tinynerdgames.com/blog.html
I want this page's URL to not end with /blog.html rather with /blog. So the wished end result would be: www.tinynerdgames.com/blog
What do I have to do?
Any answer is highly appreciated, thank you.
You can use the .htaccess file to truncate your file URL's.
Navigate to your File Manager in cPanel and locate the .htaccess file. Note: you must enable hidden files to view this file.
Click on Settings at the top right corner
Select Show hidden files (dotfiles)
Save new settings
Inside the htaccess file, paste this code;
#remove html file extension
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
Now change your link from to https://tinynerdgames.com/blog.html to https://tinynerdgames.com/blog and this should work perfectly.
Using FTP, you would log in to your website, create a directory named blog, move the blog.html file into the new directory, and rename blog.html to index.html.

How do I redirect "website/page" to "website/page.html" when people type it in browser (pretty-url)

I recently started using a static site with godaddy.com without a cms. It's a basic website I uploaded and is only html/js/css.
When people type "website.com/page" they get 404 not found.
When they type "website.com/page.html" they get the correct page.
How can I fix my site so users can simply type "website/page" and not be forced to type "website/page.html" without using php?
SOLUTION
After researching the information about .htaccess files provided by #Gijsberts (thank you), I did the following:
Created a .htaccess file on server.
Added the following code:
# Remove the .html extension from html files
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]
Most CMS systems have a .htaccess file what handles the redirect and the 404 errors. In CMS system they are most called "Pretty-urls". Read the links below to set up those pretty urls yourself with a static web page without a cms.
https://mediatemple.net/community/products/grid/204643080/how-do-i-redirect-my-site-using-a-htaccess-file
http://code.tutsplus.com/tutorials/using-htaccess-files-for-pretty-urls--net-6049
You normally can do this with your Webserver config. In Apache you have this enabled automatically. In nginx you should have a look at this tutorial.
If you are using caddy you have to config your caddyfile like
ext .html .htm .php
if you are using microsoft iis have a look at microsofts tutorial.
Let me know if you are using something else or need more help.
EDIT
If you are using a webspace you may are not able to change the config of the webserver. you now can use .htaccess. create a .htaccess file and write down something like
Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

My domain www.digitalproductshopping.com is on a WordPress installation, Can I add a sub-directory that is html5

Can I have a HTML5 Sub Directory as part of my WordPress installation. I have put the subdirectory in public.html folder, but when i enter the URL www.digitalproductshopping.com/affiliatemoneysecret, I get a page not found 404 error on this URL.
Step 1 : create folder into your website directory ...parallel with folders : "wp-content" , "wp-admin" and "wp-includes"
Step 2 access your html page by www.yoursitename.com/folder where you can add html file and also run
The issue is basically due to .htacess rewrite rule
1)Try adding
ErrorDocument 401 default
to your htacess file , in most of the cases this should work if not then try adding
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/subdirectoryname1/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/subdirectoryname2/(.*)$ [OR]
RewriteRule ^.*$ - [L]
the sub directory was different, not in spelling but in capitalisation, in different documents, subdirectories must be spelled and capitalised exactly the same or the above error occurs.
Thanks for the effort everyone.

Clean/Short URLs using .htaccess is not working as it should

I've been following some YouTube videos to try and get this working but it doesn't seem to want to. This is how my .htaccess file is looking:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule RewriteRule ^(.*)$ index.php/$l
I am completely new to .htaccess, I'm not completely sure how it works but my common sense tells me to just create a file, call it .htaccess and place it in the same folder as my index.php, right?
So when I go to, say index.php/foo/bar or even just /foo/bar/ I get a 404 error.
What are the possible problems? It's a Windows 2008 Server with PHP 5.3.10 installed.
As beginning your last line should be
RewriteRule ^(.*)$ index.php/$l
And it should work as you expect it... pass all requests but ones for existing files/folders into index.php
The .htaccess can be in any folder which is hit by the request URL... the only difference is the base of the URL which is relative to the folder where is the .htaccess located
Example:
/folder1
.htaccess
index.php
/folder2
.htaccess
index.php
If you access /test.php none if your .htaccess files will be processed (it's not related to the request URI.
If you access /folder1/test.php the corresponding .htaccess in folder1 will be used and the $1 in your RewriteRule will show test.php, the /folder1/ will be stripped from the URI.
If you access /folder1/folder2/test.php it's similar... apache will use .htaccess from folder2... the one from folder1 will be ignored (a bit counderintuitive)