Click to See Complete Forum and Search --> : Hiding file extension in the URL
webmaster54880
06-28-2009, 09:48 PM
I have been developing websites for a while and now I am moving towards server side scripting. Something i have noticed is that alot of web sites hide the extensions of the webpages from the end of the url, like .php or .asp . I am assuming this is a sort of security measure. I know you can do this via the .htacess file, but i have no experience working with the .htaccess file.
Can someone give me simple instructions on how to this?
Thank you.
Declan1991
06-30-2009, 12:29 PM
It's just not necessary, not particularly a security measure.
Example (http://www.desilva.biz/php/phpinhtml.html).
Many website engines has no file representations for each webpage they have. So for example there is only one index.php in the root of the website, but site has thousend pages. it is done this way in .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php
This way we can dynamically set up page urls, i.e. to add key words to the url which is good for SEO
Check my site Some seo ideas (http://www.easydevelopment.info)
JavaServlet
07-05-2009, 03:23 PM
You can also hide the extension for JSP using the mapping tag located in your web.xml:
<servlet>
<servlet-name>mypage</servlet-name>
<jsp-file>/src/jsp/main.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>mypage</servlet-name>
<url-pattern>/anynamehere</url-pattern>
</servlet-mapping>