Yves without www



I noticed that frontend of demoshop doesn’t work without “www.” prefix in url. At least out of the box. What’s the easiest solution to make it run with both versions, prefixed and not ?



Hello Marcin,

The best way to handle this would be to make a redirect in nginx from ‘non-www’ to ‘www’. To do this:

  1. Log in to the VM or the machine where Spryker is installed. To log in to the VM, use the following command: vagrant ssh.
  2. Use any text editor to open the following file: /etc/nginx/sites-enabled/DE_development_yves, where DE is the language version of the shop you are using. In the VM, you can use mcedit and open the file using the following command: mcedit /etc/nginx/sites-enabled/DE_development_yves.
  3. Add the following text to the very beginning of the file (for DE shop):
    server {
        listen 80;
        server_name ~^de.demoshop.local$;
        return 301 $scheme://www.de.demoshop.local;
  4. Save the file and close it.
  5. Make changes to files for other shops, if necessary (e.g. US_development_yves, AT_development_yves, etc.).
  6. Restart nginx. To do this, execute the following command: sudo service nginx restart.
  7. If you are using the VM, you also need to make changes to the configuration of the hostmanager plugin. To do this, first, execute the exit command to close the SSH connection to your virtual machine.
  8. Open the following file on the host: %vagrantboxesdir%/devvm2.0.0/0/virtualbox/include/_Vagrantfile, where %vagrantboxesdir% is the folder where vagrant stores virtual machine settings. The folder path is:
    • ~/.vagrant.d/boxes on MacOS and Linux;
    • %USERPROFILE%/.vagrant.d/boxes on Windows.
  9. Find the following line:
    HOSTS.push [ "www#{host_suffix}.#{store}.#{domain}", "zed#{host_suffix}.#{store}.#{domain}",]
  10. Rplace it with the following 3 lines:
    yveshost = "#{host_suffix}.#{store}.#{domain}"
    yveshost[0] = ''
    HOSTS.push [ yveshost, "www#{host_suffix}.#{store}.#{domain}", "zed#{host_suffix}.#{store}.#{domain}",]
  11. Save the file and restart the VM. To do this, execute vagrant halt, then vagrant up.



I am co-worker of Marcin (OP) and I want to ask if it’s possible to handle it differently. I mean your solution imo is not a solution but just a workaround, especially when Marcin asked for:

Maybe some work on env variables passed by nginx dependent on www or lack of it in URL? Would be great if you could provide more solutions and/or suggestions :slight_smile:



We cannot provide any alternatives. Currently, that is the only possible way to do what you want. Also, it is the preferred solution from the SEO perspective. For details, you can have a look here.

Best regards,

The Forum Team