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.

JavaScript

Nick Jaques
Nick Jaques
2,022 Points

Redirect pages in HTML.

I have a site example.com , however I don't want to redirect this page, I want to be able to use example.com/kickstarter , and I want this to be a redirect. I made a file and called it kickstarter.html and on the web redirect only works if I type in example.com/kickstarter.html , can I do this without the .html on the end? I just want it to be example.com/kickstarter . Very hard to find info about this online...Please help! I have used

<!DOCTYPE HTML> <head> <script type ="text/javascript">window.location="https://www.kickstarter.com/projects/example";</script> </head>

if you create a folder named "kickstarter" in your home directory and inside this folder add a index.html - you can access this kickstarter/index.html via example.com/kickstarter

If you want to create "nice looking and search-engine friendly" urls can do the following with a .htaccess file in your home directory:

The following example turns www.yoursite.com/index.php?content=team into www.yoursite.com/team

RewriteEngine On
RewriteRule ^([^/\.]+)/?$ /index.php?content=$1 [L]

More information: http://code.tutsplus.com/tutorials/using-htaccess-files-for-pretty-urls--net-6049

Flurinduerst you're absolutely right. Post your answer in the "Add an answer" box at the bottom of the page. Right now it's formatted as a comment and you won't be able to receive credit for the answer.

Nick Jaques
Nick Jaques
2,022 Points

Thanks flurinduerst!! Much appreciated! Yes please post as an answer so I can credit you!

oh, didn't notice i added my answer as a comment :) glad to help :) thanks

1 Answer

if you create a folder named "kickstarter" in your home directory and inside this folder add a index.html - you can access this kickstarter/index.html via example.com/kickstarter

If you want to create "nice looking and search-engine friendly" urls can do the following with a .htaccess file in your home directory:

The following example turns www.yoursite.com/index.php?content=team into www.yoursite.com/team

RewriteEngine On
RewriteRule ^([^/\.]+)/?$ /index.php?content=$1 [L]

More information: http://code.tutsplus.com/tutorials/using-htaccess-files-for-pretty-urls--net-6049