In PHP, how to jump to different pages based on the URL
For example
When the user accesses
https://www/?a=*
automatically jumps to
https://www/?b=*
How should PHP code be written?
ps: The equal sign is followed by any number. According to different numbers, jump to different pages
怪我咯2017-05-16 13:18:18
I don’t understand PHP, but there is an idea.
Before the user accesses (or after accessing https://www/?a=*), first trigger a public event. This event can be written on the front end or at the end. terminal, pass a parameter to this event, and perform a second jump access based on the parameter;
For example, first visit https://www/?a=*, then jump to a blank page (it can also be made into a refresh current page ), when the page is initially loaded
$(function(){
$.ajax({
type:"Post",
url:'XXX',
data: {"a":"传的参数值"},
Success:function(result)
{
switch(result)
{
//根据需要来写
}
}
})
})
phpcn_u15822017-05-16 13:18:18
There are many methods:
phpheader
jslocation.href
Some php frameworks come with jump functions, such as tp, ci's Redirect
function, etc.
ringa_lee2017-05-16 13:18:18
<?php
$version = intval($_GET['a']);
if ($version === 1) {
header('Location: http://www.baidu.com');
} else if ($version === 2) {
header('Location: http://www.sina.com.cn');
}
某草草2017-05-16 13:18:18
<?php
$arg = isset($_GET['a']) ? $_GET['a'] : '';
if( !empty($arg) ) {
switch($arg) {
case 'one':
header('Location:'.$toUrl); //$toUrl为要跳转的链接
break;
case 'two':
/*
your code here
*/
default:
break;
}
}