내 웹 사이트 abc.com
의 index.php
페이지에 내부 링크가 몇 개 있습니다. 예 : contactus, aboutus 등 그것에.PHP 페이지가 새로운 URL로 어떻게 다시로드 될 수 있습니까?
누군가가 index.php
페이지의 링크 (contactus)를 클릭하면 요청이 index.php
이되어야합니다. 하지만 index.php
은 새 URL 인 abc.com/contactus
으로 다시로드해야합니다.
내 웹 사이트 abc.com
의 index.php
페이지에 내부 링크가 몇 개 있습니다. 예 : contactus, aboutus 등 그것에.PHP 페이지가 새로운 URL로 어떻게 다시로드 될 수 있습니까?
누군가가 index.php
페이지의 링크 (contactus)를 클릭하면 요청이 index.php
이되어야합니다. 하지만 index.php
은 새 URL 인 abc.com/contactus
으로 다시로드해야합니다.
그것은 누군가의 index.php에 다음
링크 를 클릭 할 때
<a href="index.php?link=contact_us">Contact Us</a>
같은
링크 메뉴선언 링크를 원하는대로 작동 희망
if(isset($_GET['link']))
{
$link =$_GET['link'];
if($link == 'contact_us')
{
header("location:contact_us.php");
}
}
//Contact us link
<a href="index.php?redirect_url=contact_us">Contact Us</a>
//Javascript code
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var redirect_url = getParameterByName('redirect_url');
//will redirect to contact us page after 3 seconds. You can change it as per your requirement
if(redirect_url){
setTimeout(function(){ window.location.href = redirect_url; }, 3000);
}
<?php
/*we will use this this function ob_start() in the first of php page to redirect the users after your submit data
ob -> output buffering */
ob_start();
?>
<!--for example -->
<?php
/*write this function in the first of php page*/
ob_start();
?>
<?php
/*write your Query here after you write your query you will write the page that you will direct the users for example */
header('location:index.php');
} ?>