I have made a site which consist of around 10 pages all ending with .html. ( home.html, about.html).
I wish to remove .html extension and change my URLs for example www.rajat.com/about.html to www.rajat.com/buy-products-from-me in all my webpages in an easier and less time consuming way as I have already linked my pages
Is there a way to solve this?
As htaccess was mentioned as a tag, it would be assumed your using Apache
paste this into it
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule ^$ index.php [QSA,L]
RewriteRule ^(.*)$ index.php?id=$1
so given mysite.com/about - about becomes the value of $_GET['id'] in PHP
In index.php do as you please with that variable - include($_GET['id']); or run a case on it or ...
"Roughly" how Wordpress works. index.php responds to everything; all files / pages / blog posts are handled by index.php and it's functions / classes.
Any href's link to it as above - "/about" or "/contact" or "/products"
You can use angular route(ngRoute). So all your links has a route to the file you want.
Example: Using ionic 1
.state('app.tabs.myorders', {
url: '/myorders',
views: {
'tab-myorders': {
templateUrl: 'templates/myorders.html'
}
}
})
.state('myorder', {
url: '/myorders/:myorderId',
templateUrl: 'templates/myorder.html',
})
And when you access to "/myorders" you get all into the template(all the orders), in this case it's "templates/myorders.html". In these template(myorders.html) there are links to any order like this "href="/myorders/56", where "56 is :myorderId"(order id). So, if you clicked on any link, it access to the state myorder.
More info: https://docs.angularjs.org/api/ngRoute#!
Just rename them from .html to .php like home.html -> home.php and now when you host them on server .. directly accessing them will work.
like www.yousite.com/home
this will call home.php
You have 3 options:
about.html > buy-products-from-me/index.htmlHowever, I would recommend to learn basics of Web development and some HTTP preprocessor such as PHP, also CLI, unix, nginx and Git, and you will be able to create own website and even easily deploy it with git. You may host private repositories on GitLab or for a small fee - on GitHub.
Can you give more details like, what framework you are using and where are you hosting this site?
Asma Moosagie
A tutorial on Youtube by mmtuts explain it very well using an .htaccess file.
youtube.com/watch
youtube.com/watch