Page 1 of 1

hide file extension in the url

PostPosted: 06. August 2012 14:01
by CodeVisio

I'm new of xampp and apache.

I'd like to hide the extension of my pages when a user is navigating my web site.

Current situation:
1) I successfully installed xampp 1.8.0 on my Windows 7 (x64). the folder is c:\xampp.
2) I successfully created a web site with few html pages, plus some images and a php file.
3) The web site works fine, but while browsing it in local, I see my web pages in the URI with their extensions. For example http://localhost/en/mypage.html.

How is the structure of my web site folders in local:
|-----------en (folder)

en folder contains my web pages localized for the English languages. Inside htdocs I have an Index.php file. inside it I have put some php code to redirect the browser to the appropriate folder based on the browser language. So if it is an English firefox then the en/home.html file is loaded, if it is a Dutch one the the du/[home in dutch].html etc.

I've tried some solution for hiding file extension around internet but they didn't work for me. That is, writing some rules inside an .htaccess file inside htdocs folder. The extension was still there.

Any idea?

Thank you

Re: hide file extension in the url

PostPosted: 06. August 2012 15:54
by Altrea
Hi CodeVisio,

You have a few possibilities to hide parts of the url:
  • Create a frontcontroller with PHP to implement the needed ressources on runtime instead redirect the request (as you do now)
  • use mod_rewrite (for example with a .htaccess file) to rewrite the request
  • use HTML Frames to load parts of the webpage (the url will always stay the url of the frame site.

I will not get too much into detail because i think it is beside the topic of this board here. It is no XAMPP issue.

best wishes,