I want to hide (remove) the file extension (shtml) in my web page. The website is hosted in an apache server running a linux operating system.
I have tried various codes (found in google search: removing file extension) written in .htaccess files, but give me no luck.
After keep on trying and modifying codes from several sources, finally I can get what I want:
domain/foo.shtml will be appeared as domain/foo
and if I type
domain/foo it opens the shtml page correctly and appeared as domain/foo
Basically the *.shtml will never appeared in the web browser address bar.
The codes written in .htaccess are the following:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.shtml -f
RewriteRule ^(.*)$ $1.shtml
RewriteCond %{THE_REQUEST} ^GET\s.+\.shtml
RewriteRule ^(.+)\.shtml$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.shtml -f
RewriteRule ^(.*)$ $1.shtml
RewriteCond %{THE_REQUEST} ^GET\s.+\.shtml
RewriteRule ^(.+)\.shtml$ /$1 [R=301,L]
The codes are implemented in the new Impact website. Note in IE9, some pages are greyed-out because lightbox.js does not work correctly.
The codes also work for other extensions.
ReplyDeleteThank you for showing us how it is done.
ReplyDeleteLogo Design Company
This is a very nice article on htaccess i like your article.
ReplyDeleteThank you. The link about htaccess http://www.htaccessredirect301.com/
ReplyDeleteis very useful.
I really like your blog,this blog is very useful for me in my future.Thanks to you keep it up.Here is a browser extensions you can use this your motive:- https://chrome.google.com/webstore/detail/yourls/cfmnkhhioonhiehehedmnjibmampjiab
ReplyDeletereally nice article i like your post
ReplyDeletevery nice article i will try you bookmark
ReplyDeleteWork at Home
that was really helpful.I must say you are great.
ReplyDeletetop outsourcing companies
Informative post !!!!
ReplyDeleteWeb Design Mumbai
excellent blog andnice content.hotel in manali
ReplyDeletenice post.hotels at manali
ReplyDeleteThis comment has been removed by the author.
ReplyDelete