1

I have a Shopware shop with the following Domain:

myshop.tld

Now I have created a so called »Language Shop« on the same Domain which is accessible via:

myshop.tld/en

How to protect only the new Language Shop (myshop.tld/en) with .htaccess and .htpasswd?

J.T.
  • 26
  • 2

1 Answers1

0

Try something like this in the webserver configuration (Location does not work in the .htaccess)

<Location /en>
  Require valid-user
  AuthType basic
  AuthName "Protected shop"
  AuthUserFile /your/path/.htpasswd
</Location>

See here https://stackoverflow.com/a/580067/288568

If you don't have access to the web server vhost configuration, you can use something like

SetEnvIf Request_URI "/en/.*" DENY

edit

Use

SetEnvIf Request_URI "/en.*" DENY

to match also the homepage.

in the .htaccess to define an env variable and DENY access based on this.

I recommend to use the web-server configuration (if possible) because it's easier to read.

Alex
  • 32,506
  • 16
  • 106
  • 171
  • Thank you so much for this solution. :) I tried the .htaccess solution coz I do not have access to webserer configuration. The .htaccess solution works fine... but the homepage e.g. myshop.tld/en is nevertheless accessible. It only works for all other pages, e.g. myshop.tld/en/whatever! Is there a way to fix this? – J.T. Oct 25 '21 at 14:25
  • remove the final "/" `SetEnvIf Request_URI "/en.*"` – Alex Oct 26 '21 at 16:10
  • Feel free to post your full solution – Alex Oct 26 '21 at 16:10
  • Did it work? You might want to accept the answer and vote if it helped you :-D? – Alex Oct 29 '21 at 15:20