Basic Authentication using htaccess in Advanced Topics

Start Learning Today

Subscribe for just $10 a month and gain instant access to our entire library of RapidWeaver tutorials. New videos are added every week, meaning there's always something new to watch.

There's no long term contract, you can cancel anytime, no questions asked. Find out more.

Published on Feb 23, 2016

Learn how to add basic authentication to pages on your site using an .htaccess and .htpasswd files.

Advanced Topics Series Continue your RapidWeaver learning by watching all the videos in this series!


The code you used to display the document root didn't work on my ISP server, but this did:

<?php echo getcwd() ?>

This might help others who also find the $_SERVER code doesn’t work on their site.

Written by jamsk 1 week ago

Excellent videos!!

Have you ever considered a mechanism to incorporate the .htaccess file within the RW project file itself, that would then allow it to be maintained directly from within RW and get published along with the standard RW files? Would seem to me to be a sensible place to try to maintain such a file

I had tried to do this myself using a standard HTML page within RW, but it wouldn't allow ".htaccess" to be used as a filename.

Written by bluehatweb 7 months ago

You can use an HTML page type, in the Inspector tab, change the path to / and the filename to htaccess.txt. This will allow RapidWeaver to manage the file and upload it to the server. However, yo still require FTP access to the site to change the filename from htaccess.txt to .htaccess. The reason they don't manage it at present (I believe) is because of the way hosting companies manage the htaccess file. Some don't allow it thereby breaking your site, some relocate it to /private but your site is actually in /public_html (or other folder at the same level as private). This would be a support nightmare imho.

Written by Turtle 7 months ago

Allowing .htaccess and .htpasswd files to be created/managed inside RapidWeaver is something we want to add, however as Turtle points out, it's a little more tricky that you might think. If we can find a way to reliably allow creation of these files, then we'll add it to RapidWeaver :)

Written by bencounsell 7 months ago

Excellently done Ben! Can you provide more notes in the description (the url for the htpasswd generator) with perhaps a zip file for snippets for this video would be awesome additions! Yes, I could pause the video and perform said things but thought I would ask anyway ;)

Next, how to protect your htaccess and htpasswd files from download :)

Written by Turtle 7 months ago

Ah yeah, I forgot to put the link in for the htpasswd generator, here it is:

And I plan on getting something setup for code snippets used in videos, it'll be available soon.

And and, htaccess file protection is actually in my next video, which will hopefully be online today :)

Written by bencounsell 7 months ago

Well done! I had not realized this was available. Thanks for sharing what a great resource this site is! Blessings, —Mark

Written by Mark Spaulding 7 months ago

Glad you enjoyed the video, and the site in general :)

Written by bencounsell 7 months ago

Our basic account is completely free. You'll be able to like & review addons and watch our free tutorials.