Running OXID eShop in a subdirectory

I’ve been asked several times how to run OXID eShop in a subdirectory like https://myluvelydomain.com/shop/. Actually, there are several methods to achieve this goal including the adaption of your apache vhost or via .htaccess forwarding. In this blog post I will describe how to use unix symlinks to resolve the situation as it is a very smart solution that can even be used to roll out and back between several versions of your project without any downtime.

We strongly advise to use a local development environment for running your OXID eShop project. Most likely, at some point, you want to transfer it to your production machine and will have a file structure like that on your server:

Theoretically, if your domain points to the web root (e.g. /var/www/), the shop can be run at the URL https://myluvelydomain.com/source/ – which is definitely ugly: I mean, what should “source” mean to the visitor of your shop? Very often, web hosting providers have the possibility to let the domain point to the subdirectory so you can easily let your OXID eShop project run on https://myluvelydomain.com/.

Hint: please don’t try to rename the source/ folder. You’ll definitely fail 😉

Here’s a very smart solution if you have no clue how to adapt your apache vhost: simply connect to your server via SSH, move to the root directory (see above) and set a unix symlink using this command:

ln is the command to set a link, -s is an option to define it as a symbolic instead of a hard link. source/ is your target directory and shop is the link name.

Now you have to adapt the values for sShopURL, sShopDir and sCompileDir in the file source/config.inc.php: simply point them to shop/ instead of source/.

Don’t forget to alter the rewrite base value in source/.htaccess as well.

Last step: clean up your source/tmp/ directory before you fire up your browser at https://myluvelydomain.com/shop/ and check if all alterations were successfully proceeded.


Downtimeless deployment with subdirectories

With the same method it is possible to switch back and forth between different project versions – practically without any downtime, with project folder names that could be ugly as sin, and your clients will not even notice them. I’ll show you:

Let’s say you did in fact develop on your local machine and uploaded these project states to your production server. All these versions might be connected to the same database. You just check the new state in your browser if it works for you. If so, switch to it inside the doc root using the symlink function again:

Hey, there’s a customer complaining about a bug you accidentally added with your new version – just swiftly roll back:

I think you got the idea, didn’t you? If you have any questions, please don’t hesitate to post them in the linked forum thread below

Many thanks to Joscha for sharing this knowledge and the inspiration for this blog post!

 

5.00 avg. rating (93% score) - 3 votes


Start the discussion at OXID forums