URLを変えずにやりたいのであれば、推奨はされてませんがpostを使う方法があります。
example.com/aからリダイレクトする際に、javascriptでref=aとpostし、example.com/new で、postのrefの値を見て動作を判断すればいいと思います。
a
1const action = '/post/'
2const method = 'POST'
3const data = this.$contactparam
4let form = document.createElement('form');
5form.setAttribute('action', action);
6form.setAttribute('method', method); // POSTリクエストもしくはGETリクエストを書く。
7form.style.display = 'none'; // 画面に表示しないことを指定する
8document.body.appendChild(form);
9if (data !== undefined) {
10 Object.keys(data).map((key)=>{
11 let input = document.createElement('input');
12 input.setAttribute('type', 'hidden');
13 input.setAttribute('ref', 'a'); //「name」は適切な名前に変更する。
14
15 form.appendChild(input);
16 })
17}
18console.log(form)
b
1const action = '/post/'
2const method = 'POST'
3const data = this.$contactparam
4let form = document.createElement('form');
5form.setAttribute('action', action);
6form.setAttribute('method', method); // POSTリクエストもしくはGETリクエストを書く。
7form.style.display = 'none'; // 画面に表示しないことを指定する
8document.body.appendChild(form);
9if (data !== undefined) {
10 Object.keys(data).map((key)=>{
11 let input = document.createElement('input');
12 input.setAttribute('type', 'hidden');
13 input.setAttribute('ref', 'a'); //「name」は適切な名前に変更する。
14
15 form.appendChild(input);
16 })
17}
18console.log(form)
new
1
2 var postedData = <?php echo($_POST['ref']); ?>;
3 if(postedData == "a"){
4document.write("あなたはaから来ました");
5}else if(postedData == "b"){
6document.write("あなたはbから来ました");
7}else{
8document.write("あなたはリダイレクトされていません");
9}
10