Auto redirect users to the previous page

2k views Asked by At

I want to redirect users to the previous page whenever they visit a specific page

Let's say: page123.php

I have the following code on that page that redirect users to the previous page but on click:

<script language="javascript">
$(document).ready(function() {
    $('.goback').click(function() {
        history.go(-1);
    });
});
</script>

I want to automate the process so whenever they visit that page (page123.php) they redirected back to the previous one. I'd greatly appreciate it if anyone could help me in achieving this. Thank you.

Note: I don't want to use htaccess redirection.

1

There are 1 answers

2
brso05 On

You can add this tag to your html:

<meta http-equiv="refresh" content="1;url=yoururlhere" />