WAMP - .htaccess & .htpasswd
Posted by: jheinrichs79 (---.mbteach.org)
Date: May 28, 2008 09:17PM

Hi Guys and Gals,

I'm new to WAMP.

Here few things about my setup.
-----------------------------------------
My Os is Vista.. Ok enough snickers... winking smiley
I will be working with "notepad" to edit the files. I am using "Unicode".

I use this website to configure my files: [www.htaccesstools.com]


Wamp is installed to: C:\users\%username%\WAMP

I am putting the .htaccess & .htpassd files in .\php\private\ folder where "." is the "www" folder.
I am also puting in an "index.html" file in the directory with "Hello World" in it.

I have also checked off "rewrite_module" as I hear this is required. I've shut down Apache and restarted it after enabling it.
------------------------------------------

When I go to [localhost] -> Everything works. The propper page loads.
When I go to [localhost] -> I get this error message:

****************
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
*****************

I went to the server log and it says:
[Wed May 28 14:12:38 2008] [alert] [client 127.0.0.1] C:/Users/%user%/wamp/www/php/private/.htaccess: Invalid command '\xff\xfeA', perhaps misspelled or defined by a module not included in the server configuration


Any ideas?

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: toivo (---.nsw.bigpond.net.au)
Date: May 28, 2008 11:07PM

Hi,

An example of the .htaccess file you have generated would be helpful because a syntax error could explain the why the server stops with the 500 error.

You say WAMP is installed in C:\users\%username%\WAMP. Are you perhaps planning to install several copies of WAMP, or do you mean the document root for each user is in that folder, which means that you would have as many virtual hosts as you have users?


Regards,

toivo
Sydney, Australia

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: jheinrichs79 (---.mbteach.org)
Date: May 28, 2008 11:27PM

Thanks Toivo,

I am sorry I didn't post the files.

.htaccess contents are:
-----------------------------
AuthType Basic
AuthName "My Protected Area"
AuthUserFile .htpasswd
Require valid-user
-----------------------------

.htpasswd contents are:
-----------------------------
admin: xxxxxxxxx <--- This password (The whole line for that matter was created using the link I mentioned earlier
-----------------------------


I am just starting to learn PHP. I am only using one "hosting server". This is run on my laptop as a development platform

I found that if I installed WAMP to "C:\program files\" that WAMP under Vista with UAC enabled didn't work so hot.

What I did to get around this was install WAMP to "C:\Users\Jared\WAMP"
My Web directory would then be located in "C:\Users\Jared\WAMP\www"

For each lesson or project I am creating a sub-folder under "www".

for example I created a project in a subfolder called "PHP" under "www". C:\Users\Jared\WAMP\www\php"
In that project folder I want to create a folder called "private". The reason being is I want to put in a php file with "login" credentials for example but I don't want anyone else seeing it unless they enter a propper password:

// ** MySQL settings ** //
define('DB_NAME', 'test'); // The name of the database
define('DB_USER', 'test'); // Your MySQL username
define('DB_PASSWORD', 'test'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

I hope that this helps you understand what I am trying to do.

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: jheinrichs79 (---.mbteach.org)
Date: May 28, 2008 11:30PM

BTW.. Both .htaccess and .htpasswd are both located in the same directory:
"C:\Users\Jared\WAMP\www\php\private"

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: yfastud (Moderator)
Date: May 28, 2008 11:44PM

You need to use full path in .htaccess

AuthType Basic
AuthName "My Protected Area"
AuthUserFile C:/Users/Jared/WAMP/www/php/private/.htpasswd
Require valid-user

BTW, that encryption is for *nix and won't work in windows, so you need plain word or md5 encryption; for example

admin:pass

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: jheinrichs79 (---.wp.shawcable.net)
Date: May 29, 2008 04:09PM

Hey guys this still didn't work:

Getting the same error on Apache log.
[Thu May 29 09:00:00 2008] [alert] [client 127.0.0.1] C:/Users/Jared/wamp/www/php/private/.htaccess: Invalid command '\xff\xfeA', perhaps misspelled or defined by a module not included in the server configuration

.htaccess contents:
------------------------
AuthType Basic
AuthName "My Protected Area"
AuthUserFile C:/Users/Jared/WAMP/www/php/private/.htpasswd
Require valid-user
-------------------------

.htpasswd contents:
-------------------------
admin:admin <--- exact line --- No longer encrypted.
-------------------------

When you go to [localhost] it reports:
-------------------------------------
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
-------------------------------------

Any other ideas?

I am using notepad to write these files and I am saving them with "unicode" encoding. do these files need to be saved as something else? I know notepad supports ANSI, Unicode, Unicode BIG, and UTF-8.

Thanks for the quick responses! smiling smiley

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: yfastud (Moderator)
Date: May 30, 2008 05:44PM

Make sure you don't save file w/ hidden .txt

Check your Private Message ;-)

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: jheinrichs79 (---.mtsdbp.ca)
Date: May 30, 2008 05:50PM

Thanks for replying but I made sure that the file is really ".htaccess" and not ".htaccess.txt"
the only reason why I mentioned I was creating the files with notepad and the encoding is that I read somewhere that .htaccess files need to be saved using a very specific encoding. The person failed to mention what type of file encoding it needed.

The funny thing is I've got .htaccess/.htpasswd working on a hosting provider that uses a lamp stack.
I just don't know why this doesn't work on WAMP.


Any other ideas?

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: Jamesking55 (---.range81-152.btcentralplus.com)
Date: June 07, 2008 06:29PM

I just used an online generator to generate a htaccess and a htpasswd file for you:

They are below:

.htaccess:
------------------------
AuthName "Restricted Area"
AuthType Basic
AuthUserFile C:/Users/Jared/WAMP/www/php/private/.htpasswd
AuthGroupFile /dev/null
<Files index.html>
require valid-user
</Files>
-----------------------
.htpasswd
-----------------------
admin:A7MW1yf/7vOG6
-----------------------


now try this and see if you can login

login is:

username: admin

Password: admin



Tell me if it works!




btw the generator is here: [www.tools.dynamicdrive.com]



James

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: taky (---.dsl.phnet.fi)
Date: October 16, 2008 08:35PM

jheinrichs79 Wrote:
> ****************
....

> Please contact the server administrator,
> admin@localhost and inform them of the time the
> error occurred, and anything you might have done
> that may have caused the error.
....


I have same problem as you with WampServer 2.0c .

Is your system ok now?
If, can you tell me how you fix problem?

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: yfastud (Moderator)
Date: October 16, 2008 10:00PM


Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: taky (---.dsl.phnet.fi)
Date: October 17, 2008 08:22PM

yfastud Wrote:
-------------------------------------------------------
> try plain text to make sure it works first

---

I try it but it don't help.

apache_error.log tell....

------------
[error] [client 62.165.xxx.yyy] access to /kml failed, reason: require directives present and no Authoritative handler.
[error] [client 62.165.xxx.yyy] user test: authentication failure for "/kml": Password Mismatch
------------

Password is absolute correct.

.htaccess is
----
AuthType Basic
AuthName "Server"
AuthUserFile "C:\wamp\www\user\.htpasswd"
Require valis-user
----

.htpasswd is in /www/user -directory, and include .....
----
xxxxxxx:yyyyyyyyy
----

plain text both user and password.


I don't undestand what is wrong in my WAMP-system....

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: yfastud (Moderator)
Date: October 18, 2008 05:50AM

Quote

AuthUserFile "C:\wamp\www\user\.htpasswd"
forward flash, not backward flash and no double quote

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: taky (---.dsl.phnet.fi)
Date: October 18, 2008 09:48AM

yfastud Wrote:
-------------------------------------------------------
> > AuthUserFile "C:\wamp\www\user\.htpasswd"
> forward flash, not backward flash and no double
----

Like that...
---
AuthType Basic
AuthName "Server"
AuthUserFile C:/wamp/www/user/.htpasswd
Require valis-user
---

... but it don't help - same error.

apache_error.log
[error] [client 62.165.xxx.yyy] access to /kml failed, reason: require directives present and no Authoritative handler.

and

access.log
62.165.xxx.yyy - xxxxxxx [18/Oct/2008:10:38:17 +0300] "GET /kml HTTP/1.1" 401 401

Is possible, it is depend on Windows user right?
I have admin right's.

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: sreg0r (---.lns10.mel4.internode.on.net)
Date: October 30, 2008 03:07AM

Following this thread I used the .htaccess below and all is working fine

AuthUserFile C:/wamp/www/.htpasswd
AuthName "Restricted Area"
AuthType Basic
Require valid-user

I have a directory C:/wamp/www/testdir that I want to be public (ie no password required to view) how do I go about doing this?

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: yfastud (Moderator)
Date: October 30, 2008 12:42PM

put .htaccess in subfolder of testdir, not above, or completely different folder

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: amol_ikke (---.mysipl.com)
Date: March 12, 2011 05:24AM

I think to execute the commands in .htaccess files the rewrite module of the apache should be enabled but it is disabled by default.


If you are using WAMP then just click on the wamp server icon in the taskbar -> Apache -> Apache Modules. This will show u the list of modules.Then scroll down to find rewrite_module and click on it. When u click on it WAMP gets restarted with rewrite_module enabled.

So I think if you activate this module then it might solve your problem.


Good Luck....!

Options: ReplyQuote
Re: WAMP - .htaccess & .htpasswd
Posted by: ahmadalfy (---.static.link.com.eg)
Date: September 25, 2011 01:53PM

My OS is Windows and I had the same issue and I had two problems I had to fix :

1- I didn't set the absolute path to the .htpasswd file
2- My password was encoded.

I set the path absolutely, like this:

C:\Ahmad\wamp\www\folder\.htpasswd

and wrote the password regularly

Thanks for helping!

Options: ReplyQuote


Sorry, only registered users may post in this forum.