Jump to content

.htaccess Password for Shop


Recommended Posts

Hello,

 

I would like to give my shop a password-protection as an alternative for the maintenance mode.

But I guess I'm doing something wrong...

 

1. Where do I place this file? I thought in the root-folder of the shop, which would be /httpdocs...?

 

2. There is already a .htaccess file. Can I just paste the password-part inside it? Anyplace? Somewhere specific?

 

 

That's what I did, at least I thought so. But there won't be any pop-up that asks for a password...

 

Link to comment
Share on other sites

  • 2 weeks later...

for this it's best to search outside of PrestaShop as it's serve specific.

 

http://www.htaccesstools.com/htaccess-authentication/

 

https://www.digitalocean.com/community/tutorials/how-to-set-up-password-authentication-with-apache-on-ubuntu-14-04

 

and there a lot more out there.

 

Thank you for those. 

But I already googled and tried that. So my initial question is more about what I'm doing wrong. Because right now I see zero effect after setting it up :/

Link to comment
Share on other sites

you have to add something like this into your .htaccess file:

AuthName "Forbidden"
AuthType Basic
AuthUserFile /var/www/yourdomain/.htpasswd
Require valid-user
And then add the user:password hash into htpasswd
  • Like 1
Link to comment
Share on other sites

Well try this, used on one site and was working. In your PrestaShop root  .htaccess after #end line add this

Order deny,allow
Deny from all
AuthType Basic
require valid-user
AuthUserFile "/home/yourhostingaccount/.htpasswds/public_html/passwd"
AuthName "Protected public_html"
Satisfy Any

ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=/failed.html\"></html>"

Important thing is full path to paswd file in AuthUserFile. Change to your real  hosting account.

For passwd file you use generator El Patron mentioned http://www.htaccesstools.com/htpasswd-generator/.

Also note that part after .htpasswds. You need to create folders there that match your root prestashop folder.

Here is just public_html.

 

You can also add line

Allow from 1.1.1.1 and change IP to one that access a lot and should bypass password prompt.

 

If password is wrong you could add error document failed.html that is on same level like puplic_html

  • Like 1
Link to comment
Share on other sites

I guess one thing that was missing was the line "Require valid-user".

 

I managed to at least get the Login-Popup, but after entering the password, I got redirected to an error-page. 

So there was probably still something wrong with the path to the password-file. 

While investigating the correct part, I found an option to activate a password in the server's controlpannel, which turned out to be the most easiest way.

 

But thanks to everyone who answered. I'll mark razaro's answer as the solution, because I guess it might be the most useful one if others someday search this thread.

 

Link to comment
Share on other sites

  • 11 months later...
  • 3 months later...

Hi there,

i used .htaccess and .htpasswd to make my Pestashop password protected.

The user/pass form shows up and when i enter the correct credentials i can enter the site.

But there are no images no css, etc... seems only plain text...

Any advice?

Thanks

----------------------------------

Ok i found a suitable solution. I used Cpanel protected directories.

Now in .htaccess file i see this: (if someone has no Cpanel)

# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
AuthUserFile "/home/user/.htpasswds/domain.com/passwd"
AuthType Basic
AuthName "Protected Area"
require valid-user

Note that passwd is saved outside the root dir.

Edited by espacious
Solution found (see edit history)
Link to comment
Share on other sites

One last thing. If i enter a wrong password i dont get redirected to an error page intead the enter user/pass window shows again over and over.

.htaccess looks like this:

Order deny,allow
Deny from all
AuthType Basic
require valid-user
AuthUserFile "/home/yourhostingaccount/.htpasswds/public_html/passwd"
AuthName "Protected public_html"
Satisfy Any

ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=/failed.html\"></html>"
Edited by espacious
misclick (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...