Redirect a Page with JS

Update: gpEasy now has build in redirection. See the "missing links" in your menu bar. Nonetheless, there may be ocassion when you need to use the following method to redirect a page, maybe a html file you have in a directory.

This is a very simple tutorial to share a peace of code I got on the gpEasy forum to redirect a page within gpEasy. What this tutorial will teach you is how to apply a specific peace of JavaScript to a gpEasy page to make it redirect to another gpEasy page. Why would you want to do this? Maybe you have an old page in which you changed the URL and just want a simple easy redirect. Maybe you need a placeholder in your File Manager or nav menu. There are lots of potential reasons to use this little peace of code. Luckily it's very very simple to apply.

The Code:

<script type="text/javascript">

That's all there is to it. One line of code with the opening and closing tags for JavaScript. Notice the ""? That's the page this is redirecting to. So if you are redirecting to an internal page within gpEasy you would just use the relative link.

For example let's say I want to redirect a page to my main gpEasy CMS page from within the same installation of gpEasy. The code would look like this,

<script type="text/javascript">

Notice that I'm using the relative link to my gpEasy CMS page or the "page slug" if you prefer.

How to apply it?
Simply create a new page that you want to redirect to another page. Edit that page and click the "source" button on the HTML editor. Then paste the above code into the source view, you might as well delete all other text in the page as well. Change the link in the JS to the page you want to display, or rather be redirected to. Then save. That's it.

You can redirect easily within your gpEasy installation by using relative links. If you want to redirect to an external page then use the absolute link for the page you want to be redirect to.


Once this code is saved in a page that page will not display because it will instantly redirect. Therefore, when you want to edit the page you will need to go to the File Manager and edit the page via its file options.

Other than that there really isn't much to it.


gpEasy B2sq Theme by CS @True Acupuncture