π¬π§ Netlify redirect info
Save a plain text file called _redirects to the publish directory of your site.
In a _redirects file, each redirect rule must be listed on a separate line, with the original path followed by the new path or URL. Any line beginning with # will be ignored as a comment.
Here is an example:
The following example uses _redirects file syntax:
HTTP status codes
HTTP status codes are sent in server responses to the client or browser. The code gives information about the type of response.
You can specify the HTTP status code for any redirect rule. If left unspecified, the default is 301.
Here are some examples of status codes you might use:
-
301 (default): Permanent redirect. Tells the client that the address for this resource has permanently changed, and any indexes using the old address should start using the new one. The URL in the browser address bar will display the new address.
-
302: Temporary redirect. Tells the client that the current address change is temporary. The URL in the browser address bar will display the new address.
-
404: βNot foundβ. You can use this status code to present custom 404 pages when visitors access paths on your site that donβt exist. With this status code, the page content will change, but the URL in the browser address bar will not.
-
200: βOKβ. Redirects with this status code will change the server response without changing the URL in the browser address bar. This is used for rewrites and proxying.
Here are some example redirect rules with status codes:
Redirect with a 301
/home / 301
Redirect with a 302
/my-redirect / 302
Show a custom 404 for this path
/ecommerce /store-closed 404
Rewrite a path
/pass-through /index.html 200