How To Hide .html Extension In Url Using Javascript
Is there any way to hide .html extension from URL using JavaScript. FOR ex: mysite.html hide.html here from url
Solution 1:
You cannot achieve this through javascript, this need to be done through .htaccess
file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
More information about mod_rewrite
module here.
Solution 2:
You can with html5, but also you can use url rewriting, or seo friendly urls, on the server side.
window.history.pushState({"html":'<html></html>',"pageTitle":'this is my title'},"", 'http://stackoverflow.com/mynewurl');
However keep in mind you can only change the url to one which is the same domain as the original!
There is a great library called history.js which helps with cross browser and version compatibility
Post a Comment for "How To Hide .html Extension In Url Using Javascript"