php - How to jump to different pages based on the URL
某草草
某草草 2017-05-16 13:16:18
0
5
839

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

某草草
某草草

reply all(5)
刘奇

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)
            {
                //根据需要来写
            }
        }
    })
})
刘奇

Get the number
Judge based on the number
headerJump

phpcn_u1582

There are many methods:

  • phpheader

  • jslocation.href

  • Some php frameworks come with jump functions, such as tp, ci's Redirectfunction, etc.

左手右手慢动作
<?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');
}
某草草
<?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;     
 }
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template