1

As I asked it in the title, I decided to move my Magento Store to a subdomain. I created a showcase site that is published at my main domain.

The thing is my store was published for 2 years and even if I didn't work on SEO improvments, my website was listed and my URLs were crawled by Google.

I was wondering if it was existing a template/a way to redirect all the previous URL of my store in the subdomain.

Is it a good practice to do it or doesn't it matter ? Thanks !

1 Answer 1

0

I think your Magento store has a large number of products, and categories, so your Magento store has many URLs that do not follow any rules, eg:

Product URLs:

  • domain.com/table-a.html
  • domain.com/short-pant-a.com
  • ...

So you should redirect all URLs from the main website to the subdomain but also skip redirect the main website's URLs.

Try the following config for Nginx:

server {
    listen 80;
    server_name domain.com;
    set $WEB_ROOT /path/to/mainwebsite/root;
    ...

    # Redirect all URLs to subdomain 
    location / {
        return 301 $scheme://sub.domain.com$request_uri;
    }

    # Keep the below URLs stay in the main website
    location ~/(url-part-1|url-part-2|url-part-3) {
        root $WEB_ROOT;
        ...
    }
}
2
  • I didn't mention that I use Nginx and not Apache ; but anyway I know how to create redirections, I just want to know if there is an exhaustive list of redirects to do ; and I'm still using the main domain for my showcase website so I don't want to redirect all the requests to the subdomain
    – Paul
    Commented Oct 16, 2022 at 21:22
  • I've updated the answer, please check.
    – Tu Van
    Commented Oct 17, 2022 at 5:02

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.