Jump to content
sonu

PHP Redirect

Recommended Posts

Hi,Friends I need small help.I know it is not an big issue for PHP Experts.I need a redirect code like the example below:If user tries to visit www.domain.com/page1.php then it should redirect to home page means index.phpI need to redirect only 1 particular page not all pages.I will insert this code in index.php .Then,if user tries to visit page1.php then it should be redirected to page2.php .But,the code should redirect only if user trying to access page1.Thanks in Advance! Help me Guys.

Share this post


Link to post
Share on other sites
header('location:http://yoururl.com');

resource: http://php.net/header

Share this post


Link to post
Share on other sites

Hi,Thanks for your reply.I need it to give condition like if user is accessing page1.php then he should redirect to page2.php .

Share this post


Link to post
Share on other sites

you can paste that redirect header in page1.php and point to redirect to page2.php. so that if anyone comes into page1 will be redirected to page2

Share this post


Link to post
Share on other sites

you have to put that code in your sub page. and http://yoururl.com will be replaced with your site nameheader('location:http://yoururl.com');

Share this post


Link to post
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.

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...