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

PHP

Writing to an .htaccess File

I spent an amount of time that I cannot get back trying to figure out how to write to an .htaccess file using Treehouse workspaces. What I learned is that @alenaholligan had already taught me how to do this at the 1:48 mark of this tutorial.

In essence, to write to this file type, which is reserved for system configurations, modify the extension to read htaccess.txt. This allows the file to be written on. Add your rules then rename the file as .htaccess and it is now functional.

To view (or check) the contents of this file using the console, type vim .htaccess and all of the rules will be displayed!

1 Answer

Hey MM - Me again haha. Here are the steps I took to create and edit an .htaccess file in workspaces.

Step 1 - In console $ vi .htaccess

Step 2 - Add your content to the .htaccess file.

Step 3 - :wq to write the contents.

In the workspaces sidebar, right click the parent folder then click 'refresh'.

The .htaccess file should be there.

Hope that helps.

Cheers,

Ben