gary4u Posted September 30, 2018 Share Posted September 30, 2018 Hi, I have created a index.html page for a Disclaimer and then after click go to the main.php file. Can I know how to let search engines first go to the index and not the main.php page. eg: If you type www.mywebsite.com - then it will go to the index file. But if you type in the search engine like- www.mywebsite.com contact - it goes straight to the main.php. Which I do not want it to go. Can any help me regarding this. Thanks Quote Link to comment Share on other sites More sharing options...
requinix Posted September 30, 2018 Share Posted September 30, 2018 Actually the problem is that your site lets users go directly to main.php. You need to make sure they go through index.html first. You do that with a cookie and a redirect. Have index.html set a cookie. If main.php (or any other page) sees that the cookie is not set, it redirects to index.html. Quote Link to comment Share on other sites More sharing options...
gary4u Posted October 1, 2018 Author Share Posted October 1, 2018 Hi, Thank you for your response. Do you have any code for this. It will be very helpful for me. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 1, 2018 Share Posted October 1, 2018 It varies a bit. What is the index.html supposed to do? Why do users need to see it first? Quote Link to comment Share on other sites More sharing options...
gary4u Posted October 1, 2018 Author Share Posted October 1, 2018 it just simple. When ever a user open the website it first go to the index.html. As this a Disclaimer info then after click IAGREE then it goes to the main.php. This is the site - www.letsarbitrate.com But when I noticed that when a user types in any search engines the website name --www.letsarbitrate.com contact or www.letsarbitrate.com gallery or anything for that mattter. it goes to the main.php. Which I need to restrict it to the index.html that is the Disclaimer page after they click the " I Agree " then it should go to the main.php. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 1, 2018 Share Posted October 1, 2018 That sort of thing is really better suited as a banner or popup on the page - not something separate to redirect with. Plus having it on the page means you don't have to deal with redirecting to or from it. Code it into the page so it looks like you want. Use PHP to render it onto the page if the cookie isn't set, then use Javascript to set the cookie and remove the message. Quote Link to comment Share on other sites More sharing options...
gary4u Posted October 1, 2018 Author Share Posted October 1, 2018 I have tried all sort of ways to redirect but it is not working. Can you please suggest me where I can get a code for this. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 1, 2018 Share Posted October 1, 2018 And I'm telling you, this redirect stuff is annoying so take the other approach that doesn't require redirecting. Besides, if you already have some code in place then me giving you even more to throw at it won't help. What code do you have and what exactly do you mean by "it is not working"? Quote Link to comment Share on other sites More sharing options...
gary4u Posted October 1, 2018 Author Share Posted October 1, 2018 Its just some stuff like <script> function newLocation() { window.location="http://letsarbitrate.com/index.html"; } </script> Quote Link to comment Share on other sites More sharing options...
requinix Posted October 1, 2018 Share Posted October 1, 2018 Okay, so, theoretically that would work fine. If you call the function of course. But it would be better if you did it with a true redirect through PHP. What's the rest of the code? Quote Link to comment Share on other sites More sharing options...
gary4u Posted October 1, 2018 Author Share Posted October 1, 2018 Sorry for the later response. <script type="text/javascript"> function loadNewDoc(){ window.location="http://www.letsarbitrate.com/index.htm"; } </script> </head> <body onLoad="setTimeout('loadNewDoc()', 5000)"> But there might be a problem , whenever the page loads this script will run. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 1, 2018 Share Posted October 1, 2018 Right. You need something smarter. Whether you go with what I said or continue with this, you need to learn to use cookies. When the visitor sees the index.html page you must set a cookie indicating that they have seen it. Then on other pages you only redirect to it if the cookie isn't set. But keep in mind what you're doing is bad for SEO. Either you present a popup or you don't let the visitor even see main.php at all and do the redirect from the server. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.