---
name: "Ns_ConnRedirect"
section: "3aolserver"
platform: "linux"
package: "aolserver4-dev"
version: "4.5.1-18.1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/Ns_ConnRedirect/3aolserver"
---

# Ns\_ConnRedirect(3aolserver)

Internally redirect a request to a new local url

```

```

## NAME

Ns\_ConnRedirect - Internally redirect a request to a new local url

## SYNOPSIS

```
#include "ns.h"

int
Ns_ConnRedirect(conn, url)
```

## ARGUMENTS

- Ns\_Conn *conn* (in)

  Pointer to open connection.

- char *\*url* (in)

  Pointer to string of local url.

  ```

  ```

## DESCRIPTION

This routine can be used to internally redirect to a new, local url on the server.  The *url* paramter specifies a path relative to the server, i.e., without the leading "http://host:port" portion. The server will reset the Ns\_Request structure in the open connection pointed to by *conn* and restart connection handling, including authorization checks.  The result is a standard AOLserver request procedure result code, either from an underlying call to **Ns\_ConnRunRequest** or the result of one of the authorization response routines such as **Ns\_ConnReturnForbidden**.  Filter callbacks, if any, are not run again with the updated connection.

The **Ns\_ConnRedirect** routine is used internally in the server to support the basic file serving code (i.e., "fastpath") to redirect to specific files when a directory is opened and by the **Ns\_RegisterRedirect** routine to map standard reponse routines to user-provided local url's.

## EXAMPLE

The following example demonstrates redirecting to an ADP help page within a custom C-level request callback whenever a ?help=topic query argument is present:

```
	int
	MyRequest(void *arg, Ns_Conn *conn)
	{
		Ns_Set *query = Ns_ConnGetQuery(conn);
		/* Redirect to help.adp for /myrequest?help=topic calls. */
		if (Ns_SetGet(query, "help")) != NULL) {
			return Ns_ConnReturnRedirect(conn, "/help.adp");
		}
		...  handle non-help requests ...
	}
```

## SEE ALSO

Ns\_RegisterRedirct(3), [Ns\_ConnRunRequest(3)](/Ns_ConnRunRequest/3.md), [Ns\_AuthorizeRequest(3)](/Ns_AuthorizeRequest/3.md)

## KEYWORDS

connection, redirect
