IIS10 redirect while passing original url

markaspirenet 0 Reputation points
2023-04-11T13:42:59.34+00:00

I tried to resolve this with a 404/302 redirect on IIS10 but it does not work as it do I need to redirect users to a ColdFusion page where I can slice up the original URL to obtain a keyword within the URL. The URL will be nonexistent and therefore a 404 Example https://SomeSite.com/Keyword The URL does not exist and I want to capture the "Keyword" part of the URL, which I can do in ColdFusion slicing up the URL. However, as IIS does not pass the original link over I lose it. The question is, is there a way to set up a redirect for 404's to a particular URL and also have it include the original URL in the redirected link so I can pick it up? Thanks Mark

Windows development Internet Information Services
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Yurong Dai-MSFT 2,846 Reputation points Microsoft External Staff
    2023-04-12T07:16:32.28+00:00

    Hi @markaspirenet

    In IIS, you can set a custom 404 error page to point to your ColdFusion page. Please open IIS Manager and select your website, then open the "Error Pages" module, find the 404 status code and double-click to open it, and in the "Response Action" section, do one of the following:

    1. Select Insert content from static file into the error response to serve static content, for example, an .html file, for the custom error.
    2. Select Execute a URL on this site to serve dynamic content, for example, an .asp file for the custom error.
    3. Select Respond with a 302 redirect to redirect client browsers to a different URL that contains the custom error file.

    In the File path text box, type the path of the custom error page if you chose Insert content from static file into the error response or the URL of the custom error page if you use either the Execute a URL on this site or Respond with a 302 redirect, and then click OK.

    What you need to do is enter the URL of the ColdFusion page you want to redirect users to in the "Redirect to" field.

    But for what you said, "Include the original URL in the redirected link", my understanding is to pass back the original value of HTTP_REFERER as a query string parameter for 301/302. If that's the case, you probably need a custom ASP to do the actual redirection, using Response.Redirect() instead of relying on built-in IIS functionality.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the email notification for this thread.

    Best regards,

    Yurong Dai

    0 comments No comments

  2. markaspirenet 0 Reputation points
    2023-04-12T09:12:52.88+00:00

    Thanks for the reply. I did try that previously. The problem was that when IIS makes the redirect to the ColdFusion page it does not include the original refer information, the HTTP_REFERER is empty


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.