Wuhtzu Posted February 28, 2007 Share Posted February 28, 2007 Hey I have two domains: www.domain1.com www.domain2.com When a visitor enters www.domain1.com I want him/her to see: "The website has moved. Redirecting to www.domain2.com" and then of course be redirected. But how do I do this properly? Here I especially think of doing it right according to W3.org: http://www.w3.org/QA/Tips/reback I should avoid using <META HTTP-EQUIV=REFRESH CONTENT="1; URL=www.domain2.com"> but if I can't use that, how shall I get a textmessage displayed for, say, 3sec and then redirect using for example header("Location: www.domain2.com"); ? Hopefully you understand my problem and have a suggestion on how to do it Best regards Wuhztu Link to comment https://forums.phpfreaks.com/topic/40500-how-to-redirect-users-properly/ Share on other sites More sharing options...
Yesideez Posted February 28, 2007 Share Posted February 28, 2007 It's perfectly fine to carry on using that method but there are other ways. You can set up a redirect by logging into the control panel of the domain name as there should be an option there for it but it'll be transparent - that is, the user won't know they've been relocated unless they look at the URL. Using the method you're using now will allow users to see the domain has changed and update their bookmarks accordingly. Another method is using a ".htaccess" file on the server to redirect but again, this is transparent. Link to comment https://forums.phpfreaks.com/topic/40500-how-to-redirect-users-properly/#findComment-195942 Share on other sites More sharing options...
TRI0N Posted February 28, 2007 Share Posted February 28, 2007 The above example are the way to do it.. If you use your way make a plain HTML file with the content that reads something like this: " We Have Moved. You Will Be Directed To The New Site In 10 Seconds. http://www.locationsofnewsite.com If you are not forwarded to the new site or don't wish to wait click the above link. " Change your meta from 1 to 10 or whatever given number. This will alow your users to take note of what is going on. Link to comment https://forums.phpfreaks.com/topic/40500-how-to-redirect-users-properly/#findComment-195946 Share on other sites More sharing options...
Yesideez Posted February 28, 2007 Share Posted February 28, 2007 TRION, well said Link to comment https://forums.phpfreaks.com/topic/40500-how-to-redirect-users-properly/#findComment-195949 Share on other sites More sharing options...
Yesideez Posted February 28, 2007 Share Posted February 28, 2007 <html> <head> <title>domain1</title> <meta http-uquiv="refresh" content="10; URL=www.domain2.com"> </head> <body> <div align="center"> We have moved, please update your bookmarks to:<br /><br /> <a href="http://www.domain2.com">http://www.domain2.com</a><br /><br /> If you are not redirected or don't want to wait click the above link. </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/40500-how-to-redirect-users-properly/#findComment-195953 Share on other sites More sharing options...
Wuhtzu Posted February 28, 2007 Author Share Posted February 28, 2007 Thanks for your input.. I know the <meta http-uquiv="refresh" content="10; URL=www.domain2.com"> will work and it does what I want to do, which is to let the visitor see message saying the site has moved and then redirect the visitor to the new url. But W3C (w3.org) recommends that the "redirecting by refreshing"-method is not used, because it breaks the users Back-button and that's why I was looking for another method. But on the other hand the user has nothing to go back to - or does he ? Take the following scenario: #1: The user is currently viewing www.google.com #2: He decides to go to www.domain1.com #3: On www.domain1.com i redirect him using <meta http-uquiv="refresh...> to www.domain2.com #4: He is now viewing www.domain2.com #5: He decides to go _back_ to www.google.com (which he should be able to do with 2 clicks on the back button) #6: He hits _back_ and gets back to www.domain1.com #7: He is redirected back to www.domain2.com again (if he does not hit the back button in 10sec, say we said content="10..") So the only thing saving me from breaking the users back-button is my redirect waits 10sec and he should be able to hit the button again within 10sec.. But I would like to skip this whole problem by using some other method, as w3.org recommends - any suggestions? Link to comment https://forums.phpfreaks.com/topic/40500-how-to-redirect-users-properly/#findComment-195975 Share on other sites More sharing options...
TRI0N Posted February 28, 2007 Share Posted February 28, 2007 You could put in a script that detected if the came from domain2 and if so to proced to history(). Link to comment https://forums.phpfreaks.com/topic/40500-how-to-redirect-users-properly/#findComment-196000 Share on other sites More sharing options...
Wuhtzu Posted February 28, 2007 Author Share Posted February 28, 2007 That certainly is an option - any other ideas? Link to comment https://forums.phpfreaks.com/topic/40500-how-to-redirect-users-properly/#findComment-196158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.