0

So; I'm currently setting up a Magento installation off the back of a WordPress multisite setup. The WP multisite has 2 sites/domains, and each site has 3 regional variants powered by mqTranslate; ala:

company1.tld/uk, company1.tld/us, company1.tld/eu company2.tld/uk, company2.tld/us, company2.tld/eu

I have got Magento installed, and out of the box with Multistore I've got it to do:

company1.tld/shop/uk etc.

But for consistency and so the site is seen 'as one' by search engines I would prefer for the URL to be formatted as:

company1.tld/uk/shop etc.

Would appreciate any advice on how best to achieve this.

Edited to add: I have attempted changing the base URL in the store, and coupled this with the following HTACCESS in the root:

  RewriteEngine On
  RewriteBase /

  RewriteRule ^([a-z]{2,3})/shop/(.*)/?$ /shop/index.php [QSA,L]
  RewriteRule ^([a-z]{2,3})/shop/?$      /shop/index.php [QSA,L]

When I then navigate to company1.tld/uk/shop, I get a Magento 404 error...

4
  • Any reason why you can't just set each stores base URL accordingly i.e. http://company1.tld/uk/shop/? Commented Sep 17, 2014 at 10:19
  • Sorry, I should have mentioned that I'd tried that - have edited OP appropriately. Any ideas would be appreciated.
    – WillPS
    Commented Sep 17, 2014 at 10:27
  • You do realise you will have duplicate content issues doing it that way. Google doesn't like subdirectory setups.
    – user2935
    Commented Sep 17, 2014 at 11:29
  • Thanks for your comment, but I'm not really sure that's true. Google seem to have no problems doing it this way: support.google.com/webmasters/answer/182192?hl=en#2 We're using a gTLD and I personally think us.domain.gtld: 1) lessens the impact of the gTLD to the customer 2) obscures the localisation behind the rather meaty gTLD. Content will be localised quite a lot (we have copywriters in all regions on project!) and /shop will be unavailable.
    – WillPS
    Commented Sep 17, 2014 at 12:29

1 Answer 1

1

You are attempting to have Magento run in a subdirectory of web root where the base URL doesn't match this install location. Without a minor modification you do get a 404 error when you do this.

Requests are reaching Magento ok so it sounds like your rewrite from web root to the subdirectory is correct but you still need to deal with the 404.

To cut a long story short, because of the difference between install location and base URL an invalid request path is created which results in a 404 as Magento cannot process the request. It's pretty easy to fix, you just need to redefine $_SERVER['SCRIPT_NAME'] at the top of index.php in your Magento install so that it matches the base URL. So in your case it sounds like it's probably currently /shop/index.php so you need to change it to /uk/shop/index.php. At the top of index.php add:

$_SERVER['SCRIPT_NAME'] = '/uk/shop/index.php';

and the store should spring to life.

For a bit more info look at this blog post I wrote a while back.

2
  • That is flipping awesome. I've been trying to figure this out for ages. Thanks so much dude.
    – WillPS
    Commented Sep 17, 2014 at 13:41
  • Glad the solution worked for you. Commented Sep 17, 2014 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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