November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
If you would like to manage the redirects within the solution you can use the Microsoft.AspNetCore.Rewrite middleware see here for examples: URL Rewrites in CMS12 (.Net 6) | Optimizely Developer Community
var options = new RewriteOptions()
.AddRedirect("/oldurl", "/newurl");
app.UseRewriter(options);
I highly recommend using a management tool for a small fee SEOToolbox is quite good for this and now compatible with CMS12 : SEO Toolbox - Episerver add-on that automatically prevents broken links
If you are looking for a free option then I have tried out Epicweb.Optimizely.RedirectManager which works also on CMS12 : Epicweb-Optimizely/Epicweb.Optimizely.RedirectManager: This .net 6 library contains a RedirectManager and admin user interface integration in an Optimizely CMS 12 and commerce 14 project. Tested with Alloy. (github.com)
Personally I prefer to create my redirects in the same format as standard IIS Rewrite XML files which can then be loaded via the following code
var streamreader = File.OpenText("IISUrlRewrite.xml");
using (streamreader)
{
var options = new RewriteOptions()
.AddIISUrlRewrite(streamreader);
app.UseRewriter(options);
}
You can also use htaccess style as shown here https://learn.microsoft.com/en-us/aspnet/core/fundamentals/url-rewriting?view=aspnetcore-6.0
One thing to be aware of in the startup.cs is placing them before
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(name: "Default", pattern: "{controller}/{action}/{id?}");
endpoints.MapControllers();
endpoints.MapRazorPages();
endpoints.MapContent();
});
Means they will override any content URLs in Optimizely but placing them after will mean they only work when there's a 404.
While tools like the RedirectManager and the Geta NotFound handler are good tools in large builds for migrations I like them as low level as possible (my latest migration had 70k rules and works fine on the DXP).
To note as gathering and generating rules from clients can be difficult to create rules I have created an open source tool for ruleset generation I've used in my last 7-8 years of migrations https://github.com/ScottReed/iis-redirect-generator
Use Geta. You'll save yourself a bunch of time. Post your issue with Geta and we should be able to help. I've just recently installed it for a client now on .net 6 and there was some tweaking I needed to do. The current documentation needs some tidying up.
If you go with Geta, make sure you're using the correct version -- some of their packages were renamed for CMS 12: https://nuget.optimizely.com/package/?id=Geta.NotFoundHandler.Optimizely
I would highly recommend Geta Not Found Handler as well. We use it on all of our CMS 12 builds and I've found the Geta team to be responsive to issues you raise on GitHub: https://github.com/Geta/geta-notfoundhandler
I agree the Geta tool is useful, we use it in all projects but there I always like to think about the type of redirects.
When I'm migrating a site with large amounts of SEO redirects (tens of thousands) I wouldn't want to put this is Geta myself. I tend to couple it with the asp.net core rewrite middleware where these are permanent migration based redirects and keep Geta clean for marketing and basic redirects.
This was in pre .NET Core but I had performance problems previously with large amounts of redirects and large amounts of 404 requests hitting the site. I've not reviewed changes for .NET Core but in previous version the tool hooked in to the not found process in code and looked up information from the stored database tables which was very slow then there were LARGE amounts of 404 requests. This may be different now if the way it works has changed but having say 50k redirects in the database and in the tool isn't needed to me if they are migration redirects from an old platform that are unlikely to change so I prefer managing those in an XML file.
Either way it's always good to think about if the tools should be used or not based on what you're doing!
We do have some standard rules which are applied before the Geta tool as Scott implies. However the highest number of redirect rules I have on a client within such a tool is around the 24K level so I won't have had the issues to the scale that say Scott has. I am however now tempted to do some testing around that.
You can install Optimizely.RedirectManager library and configure various options within the options parameter to customize how the RedirectManager behaves.
Here is how your can do that..
Open your Startup.cs file, and in the ConfigureServices method, add the following configuration:
services.AddRedirectManager(options =>
{
// Configure options here
});
Once you have the RedirectManager configured, you can define redirects.
You can add redirect rules to your codebase or import them from a file or database, depending on your requirements.
Here's an example:
// In your code, define a redirect rule
RedirectRule redirectRule = new RedirectRule
{
FromUrl = "/oldurl",
ToUrl = "/newurl",
RedirectType = RedirectType.Permanent // Use Permanent (301) or Temporary (302) as needed
};
// Add the redirect rule to the RedirectManager
_redirectManager.AddRedirect(redirectRule);
You can define multiple redirect rules.
Once done! Testing it
Now check requests to the old URLs and verify that the RedirectManager correctly redirects to the new URLs. Use browser developer tools to inspect network requests and redirects or use any online tool like redirect checker This can help you to get detail redirection chain and its status code.
I have installed Geta. Its working also but in some case it is redirecting with query parameter.
I have setup as below
Old url : /my-account/purchase-carduser##@@$(text)-+*0123text
New Url : /my-account/frequently-purchased
Wild Card : true (Checked)
Redirect Type : Permanent
Note : /my-account/purchase-carduser is 404 url.
When I open the old url
E.g http://{hostname}/my-account/purchase-carduser##@@$(text)-+*0123text
Then it redirecting to new url, but appending the parameters from old url.
http://{hostname}/my-account/frequently-purchased##@@$(text)-+*0123text.
Ideally it should redirected to new url as it is without appending any parameter.
Any Idea.
What's the best way to do a 301 redirect in Optimizely 12? I would normally do this in web.config but not sure about .Net Core. I notice there are some plugins for Optimizely but they do not work in version 12. Tried Geta and Verndale.... but they didn't work. Verndale the site wouldn't start and got an error with Geta.