# Small .htaccess problem

**URL:** <https://forum.kirupa.com/t/small-htaccess-problem/263592>\
**Category:** programming\
**Created:** [June 17, 2008, 3:01pm UTC](https://forum.kirupa.com/t/small-htaccess-problem/263592 "2008-06-17T15:01:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Awesome\_O\_4000](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@Awesome\_O\_4000](https://forum.kirupa.com/u/Awesome_O_4000)\
**Post date:** [June 17, 2008, 3:01pm UTC](https://forum.kirupa.com/t/small-htaccess-problem/263592/1 "2008-06-17T15:01:51Z")

</div>

My boss asked me this morning to password protect a site directory. No problem. The site is located at [http://www.root.com/sitedirectory](http://www.root.com/sitedirectory)

So I set up my .htaccess:

```auto

AuthUserFile /home/user/.htpasswd
AuthType Basic
AuthName "Secret!"
Require valid-user

```

And my .htpasswd:

```auto

user:encrytpedpass

```

The .htpasswd is in the root directory. The .htaccess is in the sitedirectory folder.

When you visit the url, the prompt comes up and asks you for the user/pass. But when I ented them, it asks again. So, clearly something got messed up, but I can’t think of what it could possibly be. Anyone?

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [June 17, 2008, 3:11pm UTC](https://forum.kirupa.com/t/small-htaccess-problem/263592/2 "2008-06-17T15:11:10Z")

</div>

Sorry if any of these questions sound patronizing, not my intent;

Do you have multiple .htaccess files in root/child directories to ‘sitedirectory’ that also contains an authtype?  
Do you have any redirects or header locations inside ‘sitedirectory’ files?  
Does your apache follow symlinks?

Oh, it’s good habit to tell apache that there’s no group file;

```auto

AuthGroupFile /dev/null

```

And it’s also very good practice to keep your .htpasswd file in the same folder as the .htaccess file when you nest them in directories like that. So your .htpasswd should get redone and located in /home/user/sitedirectory/

Apart from that, not sure :x

---

<div class="post-metadata">

**Author:** ![Awesome\_O\_4000](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@Awesome\_O\_4000](https://forum.kirupa.com/u/Awesome_O_4000)\
**Post date:** [June 17, 2008, 3:24pm UTC](https://forum.kirupa.com/t/small-htaccess-problem/263592/3 "2008-06-17T15:24:38Z")

</div>

> [@sekasi;2344309](#):
>
> Do you have any redirects or header locations inside ‘sitedirectory’ files?

I have one. There’s a form that redirects to another page after the submit button is clicked.

---

<div class="post-metadata">

**Author:** ![simplistik](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/simplistik/32/7747_2.png) [@simplistik](https://forum.kirupa.com/u/simplistik)\
**Post date:** [June 17, 2008, 4:31pm UTC](https://forum.kirupa.com/t/small-htaccess-problem/263592/4 "2008-06-17T16:31:30Z")

</div>

after you put it in the second time does it allow you to enter?

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [June 17, 2008, 4:37pm UTC](https://forum.kirupa.com/t/small-htaccess-problem/263592/5 "2008-06-17T16:37:24Z")

</div>

oh wait I think I know what it is.

Make sure you add a trailing slash to the directory when you access it;

ie: [www.site.com/directory](http://www.site.com/directory) (WRONG)  
[www.site.com/directory/](http://www.site.com/directory/) (RIGHT)

Add a rewrite rule to direct users from the Wrong one to the right one. Should sort your problem.

---

<div class="post-metadata">

**Author:** ![Awesome\_O\_4000](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@Awesome\_O\_4000](https://forum.kirupa.com/u/Awesome_O_4000)\
**Post date:** [June 17, 2008, 5:30pm UTC](https://forum.kirupa.com/t/small-htaccess-problem/263592/6 "2008-06-17T17:30:16Z")

</div>

I fixed it. I’m a retard. Something in the path was missing.
