2

I have set up a second website under the same magento installation which will be used as a pos for a physical store. I want to however restrict access to the website as it is not formatted for public access and there are products on there that I dont want people to purchase.

The only access we need to the 'pos' website is through an extension i.e. domain.com/pos/webpos/....

Everything else needs to be completely closed to the public (and google for SEO reasons)

Does anyone know how to go about this? Or perhaps create a redirect so everything gets directed to the 'actual' website

The actual online website for the 'public' to buy items is mydomain.com. The other 'offline pos website' is mydomain.com/pos I say 'offline' because it has products that are only sold offline in the physical store.

Therefore anyone who accesses mydomain.com/pos/....... should be directed back to mydomain.com. except if they are a store employee accessing mydomain.com/pos/webpos/ which is the only part of the 'pos' website that needs access.

2

Solution 1: Change website based on module

This is a simple solution but requires that you change the base URL for the POS website to the same as the default website. There will be no more /pos subdirectory, just example.com/webpos.

In this particular case I would set the website code based on the URL. In the .htaccess file, you can do it like this:

SetEnv MAGE_RUN_TYPE website
SetEnvIf Request_URI "^/webpos/" MAGE_RUN_CODE=pos

This way URLs starting with /pos/webpos always use the POS website (website code pos and all other URLs use the default website.

Solution 2: Redirect

If you want to keep example.com/pos/webpos as base URL for the POS website, you probably have created a subdirectory pos with its own .htaccess file. There you can add this rule to redirect every request that does not start with webpos to the same URL of the default website:

RewriteCond %{REQUEST_URI} !^/webpos
RewriteRule (.*) http://example.com/$1 [L,R=301]
  • Hi @fschmengler thanks for the input, Unfortunately I'm not having any success. Be aware I am somewhat a noob when it comes to htaccess. I assume by MAGE_RUN_CODE=your_pos_website_code you mean the store view code for the pos website therefore the code should be: MAGE_RUN_CODE=pos But when I attempt to open the address domain.com/pos it opens domain.com/pos not the default website domain.com as you suggested. Perhaps I have misunderstood? Or perhaps I have placed the code in the wrong part of the .htaccess file? – Pragman Aug 28 '16 at 21:13
  • Hi @fschmengler perhaps I was not clear enough in explaining what I need. The actual online website for the 'public' to buy items is mydomain.com. The other 'offline pos website' is mydomain.com/pos I say 'offline' because it has products that are only sold offline in the physical store. Therefore anyone who accesses mydomain.com/pos/....... should be directed back to mydomain.com. except if they are a store employee accessing mydomain.com/pos/webpos/ which is the only part of the 'pos' website that needs access. – Pragman Aug 30 '16 at 9:31
  • @ZUBU I updated the answer accordingly – Fabian Schmengler Aug 30 '16 at 9:43
  • Thank you @fschmengler but with my limited knowledge of .htaccess I think this is above my head. This would require me to create an .htaccess for a subdirectory that does not currently exist i.e. mydomain/pos/. I'll have to get my developer involved and see if he has any luck with your solution. – Pragman Sep 1 '16 at 22:26
1

For any of you that may also have this problem here is the solution we came up with. In the head.phtml template /app/design/frontend/theme/themename/template/page/html/head.phtml

we inserted this code

    <?php 
if(strstr($_SERVER['REQUEST_URI'],'/pos') && (!strstr($_SERVER['REQUEST_URI'],'/pos/webpos')))
{
    header("location: //www.mydomain.com");
    die;
}
?>

This seems to work perfectly. If anyone has a reason why this isn't good code please let me know.

I say we in the answer as I had a lot of help from a developer to do this. I'm not sure if this is the best way to do it but we also tried changing the .htaccess file without success so for us it was the best solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.