Hey, today I’ll tell you How To Hide .HTML Extension In Website Address Bar? If you want to know, keep reading this post.
First of all, let me tell you that many people make their website with HTML and PHP, etc, but when it publishes your website, the .HTML extension is displayed in the address bar of the website. Do not look good at that?
So guys, today we will tell you a way you can hide .HTML Extension by using it. And After that, you can also visit your website .HTML Extension.
Friends, you are appearing in the address bar of your custom website. To hide the .HTML extension, first, you go to the Cpanel of your website. Or go to Public_html and create a file called .htaccess.
Also Read: Best Digital Marketing Company In Dehradun, Uttarakhand?
And Then open this file. And this code which we have given you below. Or It has to be pasted into this .htaccess file.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[[^\.]+]$ $1.html [NC,L]
Let me tell you that this code can be used only for the website created by HTML. And if you have created a website with PHP, then you can use this code.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[[^\.]+]$ $1.php [NC,L]
After using Save in this code in the .htaccess file, you can make any URL of your website without .HTML and .PHP extension. You can also see the image given above. For more information, please watch this video.
So hopefully, now you can also hide your website’s .HTML extension using these codes. And if you liked this post, or you have got to learn anything from it. You can tell us in the comment box.
Besides, if you use Facebook, Twitter, and Instagram, you can follow us there too. Because we keep updating it even daily. And thank you very much for reading How To Hide .HTML Extension In Website post.
How can I hide my page name and extension in the address bar?
For example when I click on my "Home" link, it would take me to:
www.mysite.com/index.html
but instead I'd like it show in the address bar without the page name and extension, like this:
www.mysite.com/
RAN
1,4433 gold badges19 silver badges30 bronze badges
asked Jul 12, 2012 at 5:32
3
this should work.
Put this in a file called .htaccess and put it in your root directory. Only works on a apache webserver though and not locally.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule .* $0.html
answered Jul 12, 2012 at 5:49
TschallackaTschallacka
26.8k13 gold badges89 silver badges130 bronze badges
How are you writing your "Home" link?
Having said that, don't include the /index.html
portion in your anchor tag.
Also, if you wanted to show the main site URL www.mysite.com
for every local link in your site no matter the webpage your at [photo gallery, about us, etc.], wrap your whole website in a iframe that's the entire space of the viewport which will prevent the Address Bar from changing.
Reference: jsFiddle or is it???
The above jsFiddle site shows this simple iframe method described. Notice that the Address Bar is always at the same place since the iframe is receiving all the navigation interaction.
View that jsFiddle without the /show/
as seen in the Address Bar to access the Edit Page.
answered Jul 12, 2012 at 6:03
arttronicsarttronics
9,9372 gold badges25 silver badges62 bronze badges
0
Create an
.htaccess
file in your website's root directory with the following content:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^[.*]$ $1.html
When you've added the above file you can access the following url:
www.mysite.com/index.html
by using this url:
www.example.com/contactus
answered May 17, 2016 at 7:43
You can try:
window.location.href = 'WHAT LOCATION YOU WANT';
But this will reload the page. You should find the solution on the server side.
answered Jul 12, 2012 at 5:43
micnicmicnic
10.4k5 gold badges42 silver badges55 bronze badges