Changing URLs for an entire site


(M L Sanders) #1

Matrix Version:5.3.3.0

I need to change a site URL permanently, but also want every asset within that site to get a 301 redirect.

There are a LOT of relevant assets in the site, so I would like to use the ‘Create Automatic Redirects’ facility, but unfortunately this does not work if the site asset’s URL changes.

Does anyone have a direction to go in here? Is there an ‘in-Squiz’ alternative to adding a bespoke htaccess entry? If all assets were contained in a folder (for example), then changing the URL for that folder would do the trick, but this doesn’t work with the Site URL…

thanks
mark


(Aleks Bochniak) #2

Hello Mark,

If you aren’t, I would recommend that you consider using a script to change your site’s url - rather than doing it within the backend interface. https://matrix.squiz.net/manuals/server-administrator/chapters/replace-url-script

.htaccess or web server redirect will be more performant and easier to implement than something within matrix. Is there a reason why you can’t do this?


(M L Sanders) #3

Hi Alexis
Why do you recommend this: Could this script be configured to create 301 redirects for each page (my requirement)?

thanks
mark


(Marcus Fong) #4

I can’t speak for Aleks, but in my experience the great advantage of replace_url.php is that it’s very fast.

Changing a site URL through the backend is relatively slow because it results in Matrix having to recompute the URLs of each asset under the site from scratch, based on the asset’s webpath and its position in the tree. This can take a long time on a large site with many assets, and until it finishes some of your assets will have the new URLs and some will still have the old URLs. You could avoid that by doing it in two separate steps, first adding the new site URL and then removing the old site URL, but that would make an already slow operation take twice as long.

Is there a reason you absolutely need an individual 301 redirect for every single page? The replace_url.php script can’t do this because it’s performing a replace operation at the database level - the entire reason that it’s fast is because it’s changing the URLs all at once, not one by one.

If you’d rather avoid webserver-level configuration then you could look at Matrix’s Remap Rules feature:

https://matrix.squiz.net/manuals/system-management/chapters/remap-manager#Details-Screen_remap-rules

That should allow you to redirect all URLs under a particular site to the equivalent URL under a different site, using a single remap rule.


(M L Sanders) #5

Yes, there’s a reason why I need a 301 for each page!!!
This ticket is not about how to change URLs; it is specifically about getting the 301s for every page.


(Marcus Fong) #6

In that case, you should be able to create automatic remaps for each asset by performing the URL change in two steps.

First check the Remap Manager and confirm that automatic remaps are enabled. Then add the new URL to your site and wait for the Update Lookups HIPO to finish. Then remove the old URL from your site and wait for the second Update Lookups HIPO to finish.