# WedDev Redirect

**URL:** <https://forum.inductiveautomation.com/t/weddev-redirect/80035>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [October 4, 2023, 7:02pm UTC](https://forum.inductiveautomation.com/t/weddev-redirect/80035 "2023-10-04T19:02:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff.m.miller](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jeff.m.miller](https://forum.inductiveautomation.com/u/jeff.m.miller)\
**Post date:** [October 4, 2023, 7:02pm UTC](https://forum.inductiveautomation.com/t/weddev-redirect/80035/1 "2023-10-04T19:02:20Z")

</div>

I am using webdev to serve some static web pages (Help documents) in a mounted folder. I am looking for a way to redirect a 404 or 500 error to an index/home page. This is to handle cases when links from Perspective are broken.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 4, 2023, 7:25pm UTC](https://forum.inductiveautomation.com/t/weddev-redirect/80035/2 "2023-10-04T19:25:45Z")

</div>

You can't do this with the mounted folder type.  
You'd have to script it with a Python resource - take the incoming path, check the remainder, look for the file on disk, serve it if it's found. If it's not found, return a 302 or some other code with a `Location` of the index page:

> **[Redirections in HTTP - HTTP | MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections)**
>
> URL redirection, also known as URL forwarding, is a technique to give more than one URL address to a page, a form, a whole website, or a web application. HTTP has a special kind of response, called a HTTP redirect, for this operation.

Note the advice in this thread w.r.t path traversal risks:

> [@Get File Path with WebDev](https://forum.inductiveautomation.com/t/get-file-path-with-webdev/77021/4):
>
> Start by hardcoding the directory you care about into your Python endpoint. Then, you could pay attention to the remainingPath request parameter in a Python endpoint: [https://docs.inductiveautomation.com/display/DOC81/Web+Dev#WebDev-PythonResources](https://docs.inductiveautomation.com/display/DOC81/Web+Dev#WebDev-PythonResources) If it's None, then this is a request to the 'root', so you're going to use Java's File class to list the child files in that directory: [https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#listFiles()](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#listFiles()) And assemble that i…

---

<div class="post-metadata">

**Author:** ![jeff.m.miller](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jeff.m.miller](https://forum.inductiveautomation.com/u/jeff.m.miller)\
**Post date:** [October 4, 2023, 8:50pm UTC](https://forum.inductiveautomation.com/t/weddev-redirect/80035/3 "2023-10-04T20:50:54Z")

</div>

How is it severed if found? I think I understand how to setup the redirect.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 4, 2023, 9:31pm UTC](https://forum.inductiveautomation.com/t/weddev-redirect/80035/4 "2023-10-04T21:31:36Z")

</div>

Take a closer look at the linked post. I linked some methods you would use to serve the file.
