Jump to content

How to redirect multiple URLs using PHP?


SubhanUllah

Recommended Posts

Assuming each URL is a .php file then set the PHP file yo:

<?php

header (‘Location: /path/to/newUrl.php');

Exit();

If you have one PHP script with different get data:

<?php

# this is index.php. you call it with

# index.php?page=1

# to

# index.php?page=4

# you should do this with case, but this works.

If ($_GET[‘page']==1)

{

header (‘Location: /path/page1.php');

exit ();

}

If ($_GET[‘page']==2)

{

header (‘Location: /path/page2.htm');

exit ();

}

If ($_GET[‘page']==3)

{

header (‘Location: /path/page3.html');

exit ();

}

If ($_GET[‘page']==4)

{

header (‘Location: https://new.domain. com');

exit ();

}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...