Closed geertjanknapen1 closed 1 year ago
Hi there.
When redirecting on an instance of multisite, you need to create redirects within each instance of the multisite. Within each of these redirects, the Source URL is relative, but the the Target URL is absolute, meaning that you need to include the full path of the Target URL, including the locale.
In your case, you would want to have a redirect on your en
site with a Source URL of /product-one
and a Target URL of /en/products/product-one
.
Hopefully this helps. If not, please provide further information and we can try to assist you further :)
Sorry @ols-bradshaw, this issue got put on the back burner over here due to more pressing matters.
The docs on Redirects state:
Redirects are relative to the site URL, so subfolder multisite installations will not need the site root prepended to the redirect URLs e.g.
/redirect
rather than/en/redirect
for a site installed atexample.com/en
I understand that as not putting /en/
(for example) in the Target URL. But that is not the case then? (Though I'm not sure what subfolder multisite installations
means)
So, a quick recap. An example of the redirects I've tried, this was only for the EN
site for now;
Source URL | Target URL | Status Code | Is active |
---|---|---|---|
/product-one |
/products/category/product-one |
301 | Yes |
/en/product-one |
/products/category/product-one |
301 | Yes |
/product-one |
/en/products/category/product-one |
301 | Yes |
I did not have those commits active at once, when testing the second one for example, the first one was removed and all cached was cleared
None of the above do anything when navigating to mysite.test/product-one
.
/product-one
-> /products/category/product-one
be present in all sites)Any help would be greatly appreciated :)
So, I started digging into this big-time, and the solution is really simple. You should register the middleware apparently.
I registered the RedirectsMiddleware
in the Global middleware stack and now the redirects work.
use WithCandour\AardvarkSeo\Http\Middleware\RedirectsMiddleware;
protected $middleware = [
...
RedirectsMiddleware::class,
....
];
Maybe I didn't look thoroughly enough, but I see no mention of having to register the middleware yourself in the documentation on redirects (that's why I didn't), perhaps a good idea to add that to the docs.
Or if this is not the way and you should not have to register the middleware yourself, then what would be the solution and intended way to do this?
Heya,
Recently we configured a whole bunch of redirects for various URLs. Example;
/product-one
->/products/product-one
| Status: 301 | Active: Yes.However when I hit the
mysite.test/en/product-one
URL a 404 page is returned, I'm not being redirected tomysite.test/en/products/product-one
Yes, the redirects are within the proper sites (it's a multisite setup).
Something else worth noting is that we are using the
statamic/eloquent-driver
package to save Entries, Collections, etc in our database.Do I need to do something else? Did I mess up in the set up somewhere?