Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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