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

WordPress

Password protected pages not working

Hi,

I've created a password protected page for my Testimonials Page as described in Zac Gordon.

There doesn't seem to be a definitive solution for this problem on the Wordpress forum. People suggested turning off the plugins and turning them back on again but that had no effect.

10 Answers

Here's how to fix the problem (solved by Zac Gordon).

Add the following lines of code to the wp-config file after line 28, below "define DB_Host":

define('WP_HOME', 'http://www.yoursite.com'); // no trailing slash
define('WP_SITEURL', 'http://www.yoursite.com/folder'); // no trailing slash
Matt Campbell
Matt Campbell
9,767 Points

Have you got a link to the site, the plugin and what plugin or code are you using?

Can you post the link to this tutorial on password protecting web pages? I need that for some test pages to present to my client.

I've figured out the problem. The directory where Wordpress is installed is different the Site Address URL, so passwords no longer work.... How annoying :(

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

So were you able to solve the problem or just figure it out?

No, not yet. I can't seem to find a solution.

Repairing the database didn't work, I'll have to try moving to a new one...

Moving to a new database didn't work either.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Did you try installing a new WP site on the same server and testing to see if password protected pages work with that one? That was the other suggestion that post gave that could determine whether the it is perhaps a hosting issue.

I tried installing a new WP site on my server, and then on my friend's server who's site also has the same problem and it solve it. So, I'm thinking it may be a hosting issue too as both of servers are from the same service provider.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

At this point I would contact your hosting provider. Let them know what's up and list out everything you've done (and let us know how it goes!) the should be able to help you out

I've had a response from my service provider (it's taken 3 days!) and they said to add the following to the .htaccess file where Wordpress is installed:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^example.co.uk$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.co.uk$ [NC]
RewriteCond %{REQUEST_URI} !^/folder/
RewriteRule ^(.*)$ /folder/ [L]

...I've just tried this and it seems it doesn't work.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Did you change the example.com part to your URL?

Yes, and I changed the part that says "folder" to the name of the directory where Wordpress is installed on my server. It didn't seem to make a difference to a password protected page.

Zac Gordon
Zac Gordon
Treehouse Guest Teacher

Try pinging your hosting company again. I can't think of something at the moment

I did but they weren't very helpful. They basically said there's nothing wrong with their servers and I should get in contact with Wordpress :(

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

If you email me some login information for the site and FTP I can take a look at if for you :)

zac@teamtreehouse.com

Thanks!