Before forwarding the request to the selected service, the request's host header is replaced with contents of hostRewrite. The value must be from 1 to 255 characters.
Before forwarding the request to the selected backend service, the matching portion of the request's path is replaced by pathPrefixRewrite. The value must be from 1 to 1024 characters.
If specified, the pattern rewrites the URL path (based on the :path header) using the HTTP template syntax. A corresponding path_template_match must be specified. Any template variables must exist in the path_template_match field. - -At least one variable must be specified in the path_template_match field - You can omit variables from the rewritten URL - The * and ** operators cannot be matched unless they have a corresponding variable name - e.g. {format=} or {var=}. For example, a path_template_match of /static/{format=} could be rewritten as /static/content/{format} to prefix /content to the URL. Variables can also be re-ordered in a rewrite, so that /{country}/{format}/{suffix=*} can be rewritten as /content/{format}/{country}/{suffix}. At least one non-empty routeRules[].matchRules[].path_template_match is required. Only one of path_prefix_rewrite or path_template_rewrite may be specified.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-08 UTC."],[[["\u003cp\u003eThis page provides reference documentation for the \u003ccode\u003eUrlRewrite\u003c/code\u003e class within the Google Cloud Compute Engine v1 API for .NET.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eUrlRewrite\u003c/code\u003e class, which is the focus of this page, is used to modify the URL path before sending a request to a backend service.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version of this API class is 3.6.0, and there are numerous older versions of the API available that are also linked for reference.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eUrlRewrite\u003c/code\u003e class includes properties such as \u003ccode\u003eHostRewrite\u003c/code\u003e, \u003ccode\u003ePathPrefixRewrite\u003c/code\u003e, and \u003ccode\u003ePathTemplateRewrite\u003c/code\u003e, which allow for manipulation of the host header, path prefix, and URL path, respectively, before request forwarding.\u003c/p\u003e\n"],["\u003cp\u003eThis class also inherits members from \u003ccode\u003eobject\u003c/code\u003e and implements \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e interfaces, allowing for versatile object manipulation and data handling.\u003c/p\u003e\n"]]],[],null,["# Compute Engine v1 API - Class UrlRewrite (3.13.0)\n\nVersion latestkeyboard_arrow_down\n\n- [3.13.0 (latest)](/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1.UrlRewrite)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/3.12.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/3.11.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/3.10.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/3.9.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/3.8.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/3.7.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/3.6.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/3.5.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [3.4.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/3.4.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [3.3.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/3.3.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [3.2.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/3.2.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [3.1.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/3.1.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [3.0.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/3.0.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.17.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.17.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.16.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.16.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.15.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.15.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.14.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.14.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.13.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.13.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.12.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.12.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.11.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.11.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.10.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.10.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.9.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.9.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.8.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.8.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.7.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.7.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.6.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.6.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.5.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.5.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.4.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.3.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.3.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.2.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.2.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.1.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.1.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [2.0.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/2.0.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [1.4.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/1.4.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [1.3.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/1.3.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [1.2.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/1.2.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [1.1.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/1.1.0/Google.Cloud.Compute.V1.UrlRewrite)\n- [1.0.0](/dotnet/docs/reference/Google.Cloud.Compute.V1/1.0.0/Google.Cloud.Compute.V1.UrlRewrite) \n\n public sealed class UrlRewrite : IMessage\u003cUrlRewrite\u003e, IEquatable\u003cUrlRewrite\u003e, IDeepCloneable\u003cUrlRewrite\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Compute Engine v1 API class UrlRewrite.\n\nThe spec for modifying the path before sending the request to the matched backend service. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e UrlRewrite \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[UrlRewrite](/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1.UrlRewrite), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[UrlRewrite](/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1.UrlRewrite), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[UrlRewrite](/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1.UrlRewrite), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Compute.V1](/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Compute.V1.dll\n\nConstructors\n------------\n\n### UrlRewrite()\n\n public UrlRewrite()\n\n### UrlRewrite(UrlRewrite)\n\n public UrlRewrite(UrlRewrite other)\n\nProperties\n----------\n\n### HasHostRewrite\n\n public bool HasHostRewrite { get; }\n\nGets whether the \"host_rewrite\" field is set\n\n### HasPathPrefixRewrite\n\n public bool HasPathPrefixRewrite { get; }\n\nGets whether the \"path_prefix_rewrite\" field is set\n\n### HasPathTemplateRewrite\n\n public bool HasPathTemplateRewrite { get; }\n\nGets whether the \"path_template_rewrite\" field is set\n\n### HostRewrite\n\n public string HostRewrite { get; set; }\n\nBefore forwarding the request to the selected service, the request's host header is replaced with contents of hostRewrite. The value must be from 1 to 255 characters.\n\n### PathPrefixRewrite\n\n public string PathPrefixRewrite { get; set; }\n\nBefore forwarding the request to the selected backend service, the matching portion of the request's path is replaced by pathPrefixRewrite. The value must be from 1 to 1024 characters.\n\n### PathTemplateRewrite\n\n public string PathTemplateRewrite { get; set; }\n\nIf specified, the pattern rewrites the URL path (based on the :path header) using the HTTP template syntax. A corresponding path_template_match must be specified. Any template variables must exist in the path_template_match field. - -At least one variable must be specified in the path_template_match field - You can omit variables from the rewritten URL - The \\* and \\*\\* operators cannot be matched unless they have a corresponding variable name - e.g. {format=*} or {var=* *}. For example, a path_template_match of /static/{format=* *} could be rewritten as /static/content/{format} to prefix /content to the URL. Variables can also be re-ordered in a rewrite, so that /{country}/{format}/{suffix=*\\*} can be rewritten as /content/{format}/{country}/{suffix}. At least one non-empty routeRules\\[\\].matchRules\\[\\].path_template_match is required. Only one of path_prefix_rewrite or path_template_rewrite may be specified."]]