: Why are extensions often hidden on URLs? Many times I see that URL extensions are hidden (e.g. .html, .php), but not all websites do this. Why do webmasters hide the extension? Is it for security,
Many times I see that URL extensions are hidden (e.g. .html, .php), but not all websites do this.
Why do webmasters hide the extension? Is it for security, for the URL to look cleaner, or for some other purpose?
More posts by @Becky754
6 Comments
Sorted by latest first Latest Oldest Best
You hide your page extensions or not, people still can know what technology you have used. By using cURL, it's not impossible to get your technology by fetching the header information.
curl -I -L rembatvideo.ga
Then, you would see something like your technology, cache request, connection and more.
I completely agree to all the answers put above. Just adding that one of the reasons why extensions are hidden in URL is to security. Putting it simply, if you don't expose the extension in the URL, it is little hard to figure out the technology on which the application has been built. So lets say a page in made in PHP and the extension is not hidden, then a hacker could potentially figure the vulnerabilities of PHP and use it to execute some malicious activity.
This is the type of “cool” URI scheme that I aim for on my own personal website.
Personally, the reason that I started to do so (and probably many more web designer/developers too!) was after reading the article “Cool URIs don't change” – this document was written by the World Wide Web's founding father, Tim Berners-Lee.
In Tim Berners-Lee's famous article, he basically states the same reasons that
Stephen Ostermiller has in his excellent answer to this question.
To give a more specific answer to your main question, “Why extensions are hidden in URLs?” Well, I would say that the main reasons for me are:
1. To future-proof the URI:
For example, it might have sounded like a good idea at the time to use a URI like: www.example.com/page.pl where the .pl being the file exetension for a Perl script. However, thesedays, most web developers use ASP.NET or PHP for backend-scripting, so eve though today, www.example.com/page.php sounds like a better idea, eventually PHP and ASP/ASP.net will become old-fashioned. So a better idea is to just remove the extension altogether.
2. Readability and Memorability:
It is much easier for a “cool” URI to be passed to people verbally, on paper (e.g. adverts, business cards etc.), not to mention easier to remember.
3. “Hackability” *
Although I'd say that the vast majority of users these days probably go through a search engine for everything – I've even seen people who would go to the address bar and type google.com, and then use Google to literally type in ebay.com! But, I think that if I have a website based on multimedia, the URI www.example.com/video hints that the music section can be found under the URI www.example.com/audio, and so on. (I still use the address bar to go to websites – I'm fairly “old-school” about that sort of thing!)
*(Oh! “Hackability” – does that word even exist?! Well, it does now!) :-)
4. **Aesthetics:
To make them look prettier! (Blame my OCD!)
However, I have noticed by reading through various SEO-related websites, that a lot of webmasers actually append a file extensions to dynamic URIs, e.g.:
The actual URI may be: www.example.com/article
However, the webmaster will perform a rewrite to make the URI “look” static, such as: www.example.com/article.html
The logic behind this is that basically, a search engine will assign a higher ranking to static pages (which are, apparently, less likely to change). (Although I'm not exactly an expert in SEO, I personally don't buy into this idea myself – I'm guesing that with the kind of minds behind Google and Bing's algorithms, it will take slightly more than a fake file extension to con your way you into SERP pole position!)
For more information on naming URIs, I recommend reading these articles:
Tim Berners-Lee:
“Hypertext Style: Cool URIs don't change”
W3C QA Tips:
Choose URIs wisely
Managing URIs
Make readable URIs (Draft)
Make readable URIs (Updated Draft)
Brian Kelly (UK Web Focus / UKOLN - University of Bath):
“Web Focus: Guidelines for URI Naming Policies”
Hope this helps!
Totally agree as explain by "Stephen Ostermiller" but I would like to mentioned the trick behind that to hide extension of URLs. And for that you have to use .htaccess rewrite rule, here is the script that help you out:
Redirect external .php requests to extensionless URL
RewriteCond %{THE_REQUEST} ^(.+).php([#?][^ ]*)? HTTP/
RewriteRule ^(.+).php$ example.com/folder/ [R=301,L]
There are several reasons to remove extensions from URLs:
To make the URLs look cleaner
To make URLs easier to type
To make URLs easier to remember
To make URLs more SEO keyword friendly
To be able to change technologies -- if you ever want to move your site from one technology to the other, its easiest to do so without users even knowing if there are no extensions on the URLs
Keep in mind that many sites are generated by a content management system (CMS) that would make URLs look like this: /index.php?page=this-is-the-widget-page. That is particularly ugly and has far more cruft than just an extension. Rewriting to remove index.php?page= makes it much better.
Extensions are not needed on the web because servers send the type of document as a header. Web pages are served as text/html, images as image/png or image/jpeg. This lets browsers know how to render the content without using an extension to figure out that the URL contains text, HTML, PDF or image (for more information see the Wikipedia article Internet media type).
Some webmasters choose to use an extension on their URLs that matches this content type. So any text/html document would have a .html extension and any image/png document would have a .png extension. That can help when the URLs are saved to the file system where the meta data about their content type is lost. In most file systems, the program that opens the file is chosen by the extension. So even if a page is served by PHP, some webmasters remove the .php extension, and some replace it by .html.
There is also the question as to whether URLs might be better ending in trailing slash (/) when they have no extension which has a lot of discussion on Stack Overflow.
All web servers have one or more "default files". It's the file that will be displayed whenever a visitor goes to a URL that ends in a slash /, i.e. a folder.
If the default file name on your web server is index.php and a visitor goes to example.com/pagename/, they are actually accessing example.com/pagename/index.php.
If there is no trailing /, the web server is probably just re-writing the URL to remove it, since it's not necessary. This site, in fact, does that.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.