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.php I 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.
I am not sure what exactly do you mean. The redirection code would not work if you include it in index.php (unless this file would be included in page1.php, but I do not think that this is what you want). You also cannot redirect users from one page to two pages at once. In any case, I recommend you using .htaccess: http://www.htaccessredirect.net/
Based on your explanation...if a user visits page1 they should be redirected to the index. If a user visits page2 they should be redirected to page1. But in reality if a user visits page2.php they are redirected to page1.php then redirected again to index.php. You need to rethink your logic... but to redirect use header... Like so: header('Location: http://www.example.com/'); PHP:
Ok let me get this, IF... when a user visits page2.html then, you want him/her to be redirected to page1.html and then AFTER a while from page1.html to index.html ??? Right. If so, then use HTML redirect like <meta http-equiv="Refresh" content="5;url=http://www.yoursite/page2.com" /> <meta http-equiv="Refresh" content="5;url=http://www.yoursite/page1.com" /> <meta http-equiv="Refresh" content="5;url=http://www.yoursite/index.com" /> Notice the Content="5 < -- ( That means a user viewing the page will be redirected in 5 seconds ) You can modify it as you like. If you place the above three lines by order in page3.php & page2.php & page1.php all of them, no matter which one you visit first will redirect the user to index.php. for example. Create a file called page3.php and place the first of the 3 codes only in it, and the user will be redirected to page from page3.php to page2.php in five seconds. You can also include messages like, " You will be redirected to page 2 in 5 seconds. " good luck
You could add code like the following at the top of the page you wish to redirect: $URL="http://www.domain.com/"; header ("Location: $URL"); This should cleanly redirect the page as long as you have not sent any output to page1.php prior to attempting the redirect. Keep in mind it is generally cleaner and more SEO favorable to do this through .htaccess, unless your redirect is based on processing the contents of a form.
The Acronym of PHP is 'Hypertext Preprocessor'. PHP is plateform independent language.We can make website easily with the help of PHP. To Get information about PHP, I think w3schools is best site.It makes PHP understandable and easy to learn.