Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML

Isaac Asante
Isaac Asante
4,752 Points

Removing file extension on live server

Hi, so at the end of the How To make a website course, we uploaded our website to the server, but the index, about and contact pages all had their .html file extension in the address bar when they were clicked on through the live site's menu. However, most real sites' pages would only have paths like /contact, /about, instead of /contact.html, and so on... How do we remove the extension from the address? Is this thought in next tutorials?

1 Answer

Alex Heil
Alex Heil
53,534 Points

hey isaac, this is actually a little bit tricky. to remove the file extensions and leave the current structure in place you would need something called "rewrite rules" handled in your htaccess file on the server.

another option would be to use folders for this. as example, if you create a folder called contact, put your contact.html file in there and then rename the file from contact.html to index.html you would achieve the same effect. but this means you need to change your links etc.

more informations about re-write rules can be found in the 3rd chapter of the php tutorial if you're interested here: http://teamtreehouse.com/library/enhancing-a-simple-php-application-2

hope that helps ;)

Isaac Asante
Isaac Asante
4,752 Points

Thanks! I think I'll just keep going till I reach PHP tutorials. It's not so urgent in any case.