Add Custom Rewrite Rules

If you have complex rewriting requirements, follow these instructions to create NGINX rewrite rules. These redirects are also faster than plugin-based redirects.

Rewrite rules can change part or the whole URL in a request.  There are several different types of redirects, but the two most common ones are temporary (302) and permanent (301).

Defining rewrite rules

The rewrite rule consists of the following syntax:

rewrite regex URL [flag];

Example:

You've added multilingual capabilities to your store and would like to redirect the old default checkout to the /en/ on the new one:

rewrite ^/checkout https://domain.com/en/checkout/ permanent;

To use the 302 redirect change permanent to redirect.

Create a file for rewrites in wp-content

In order to add custom rewrites on WooCart:

  1. Create or upload a file to the wp-content directory named .nginx-rewrites (file needs to start with a dot)
  2. Go to the WP-CLI tab and click on Restart Workers in the toolbar.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us