{"id":8331,"date":"2023-12-08T15:21:47","date_gmt":"2023-12-08T14:21:47","guid":{"rendered":"https:\/\/www.recolize.com\/?p=8331"},"modified":"2023-12-08T15:21:47","modified_gmt":"2023-12-08T14:21:47","slug":"disable-magento-frontend-htaccess","status":"publish","type":"post","link":"https:\/\/www.recolize.com\/en\/blog\/disable-magento-frontend-htaccess\/","title":{"rendered":"Disable Magento Frontend via htaccess"},"content":{"rendered":"<section class=\"section  text-normal section-text-no-shadow section-inner-no-shadow section-normal section-opaque\"  >\n    \n    <div class=\"background-overlay grid-overlay-0 \" style=\"background-color: rgba(0,0,0,0);\"><\/div>\n\n    <div class=\"container container-vertical-default\">\n        <div class=\"row vertical-default\">\n            <div class=\"col-md-12     text-default small-screen-default\"  ><div class=\"col-text-1 text-normal  element-top-20 element-bottom-20\" data-os-animation=\"none\" data-os-animation-delay=\"0s\">\n    <p>Some days ago one of our customers approached us with the goal to disable the Magento store frontend for the public and only use the Magento backend for internal use.<br \/>\nOf course this prevents customers from purchasing your products, but in addition also minimizes possible attack vectors for the Magento software.<\/p>\n<p>With the following snippet in the Apache <code>.htaccess<\/code> file, the frontend will no longer be accessible and return a custom 404 page:<\/p>\n<pre><code>ErrorDocument 404 \/closed.html\r\n\r\nRewriteEngine on\r\n\r\nRewriteCond %{REQUEST_URI} !^\/(index.php\/)?(admin\/)?backend(.*) [NC]\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteCond %{HTTP_COOKIE} !passthrough=secret;? [NC]\r\nRewriteRule .* - [L,R=404]\r\n<\/code><\/pre>\n<p>In this snippet you have to replace the string &#8220;backend&#8221; with your Magento admin url and optionally the &#8220;secret&#8221; with a more complex password.<br \/>\nAfterwards you only have to create the <code>closed.html<\/code> maintenance page.<\/p>\n<p>As a result the Magento store frontend is no longer available and the maintenance page is shown. If you still need to access the frontend &#8211; e.g. to lookup certain values or something like that &#8211; you can manually create a cookie with name &#8220;passthrough&#8221; and value &#8220;secret&#8221; and the protected frontend will be shown.<\/p>\n<p>For nginx or Caddy webservers the procedure is very similar.<\/p>\n<\/div>\n<\/div>        <\/div>\n    <\/div>\n<\/section>\n\n","protected":false},"excerpt":{"rendered":"Some days ago one of our customers approached us with the goal to disable the Magento store frontend for the public and only use the Magento backend for internal use. Of course this prevents customers from purchasing your products, but in addition also minimizes possible attack vectors for the Magento software. With the following snippet","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[146,170,40],"tags":[],"_links":{"self":[{"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/posts\/8331"}],"collection":[{"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/comments?post=8331"}],"version-history":[{"count":6,"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/posts\/8331\/revisions"}],"predecessor-version":[{"id":8337,"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/posts\/8331\/revisions\/8337"}],"wp:attachment":[{"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/media?parent=8331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/categories?post=8331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/tags?post=8331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}