sonu Posted June 10, 2012 Share Posted June 10, 2012 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. Link to comment Share on other sites More sharing options...
birbal Posted June 10, 2012 Share Posted June 10, 2012 header('location:http://yoururl.com'); resource: http://php.net/header Link to comment Share on other sites More sharing options...
sonu Posted June 10, 2012 Author Share Posted June 10, 2012 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 . Link to comment Share on other sites More sharing options...
birbal Posted June 10, 2012 Share Posted June 10, 2012 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 Link to comment Share on other sites More sharing options...
sonu Posted June 10, 2012 Author Share Posted June 10, 2012 I am using Codeigniter.Can you guide me I want to redirect sub page to main domain. Link to comment Share on other sites More sharing options...
birbal Posted June 10, 2012 Share Posted June 10, 2012 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'); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now