I've been trying to find a way to redirect my users from my subpages to my index page when accessing the pages from e.g. google.
For example, I only want www.mydomain.com/folder/somefile.htm to be accessible from www.mydomain.com. And when users are clicking on www.mydomain.com/folder/file.htm in the Google result list I want them to be redirected to www.mydomain.com/index.php.
I've looked at different javascript solutions, but they all require frames (which I'm not using). Also had a look at some rewrite rules that can be set for Apache servers, but didn't quite understand that stuff.
I'd return to Google and resume my search if I visited your site and was redirected to your index.php instead of the specific document I was looking for...
Gheesh, you may as well remove yourself from Googles listings...
Well, the problem is that google is indexing some of my popup html-pages and without the info on their parent pages they make absolutely no sense at all.
Do you think the javascript code might cause any problems concerning the indexing of my pages at google?
Originally posted by mago
Do you think the javascript code might cause any problems concerning the indexing of my pages at google?
Let's hope so, because I'm sure most people will not appreciate being redirected from where they believed they were going... What do you expect your visitors coming from Google to do, start searching your site for the document they were looking for... I don't think so and all you will have done is waste their time...
You are going about this the wrong way... I would suggest that you read up SEO (search engine optimization) and look into NO-INDEX/NO-FOLLOW as well as placing those pages you do not wished indexed into a directory protected by .htaccess to keep the bots out...
But redirecting will only serve to drive your visitors away...
I tested your script and it works fine. Only problem is that if I use != "http://www.mydomain.com/index.php" then I can't access www.mydomain.com/folder/file.htm from e.g. http://www.mydomain.com/index.php?page=1.
Using your example, I managed to find this piece of code (which should do the trick, right?):
Bookmarks