The 302 redirect is an HTTP status code used for temporarily redirecting one URL to another. According to the HTTP/1.1 standard, redirecting to a relative URL is valid. This means the server can send a relative path to the current URL as the redirect target.
For example, if a user accesses the URL http://example.com/path1/page1.html, the server can send a 302 response instructing the browser to redirect to ../path2/page2.html. At this point, the browser resolves this relative URL, ultimately redirecting to http://example.com/path2/page2.html.
In practical applications, using a relative URL as the redirect target can effectively reduce the risk of errors while simplifying server configuration, especially during site migrations or structural changes. Relative URLs make redirects more flexible, as they do not depend on absolute paths, thus maintaining consistency across various environments.
In summary, 302 redirects to relative URLs are not only valid but also recommended in many cases because they provide higher configurability and maintainability.