Forum Moderators: phranque

Message Too Old, No Replies

.htaccess help

.htaccess newbie needs help

         

TanagerDave

5:25 pm on Jul 26, 2004 (gmt 0)



hi, i want visitors who visit my site http://example.co.uk to be instantly redirected to http://forum.example.co.uk/portal.php .. i am using the following line in my .htaccess file

RedirectMatch permanent ^/$ http://forum.example.co.uk/portal.php

this appears to work fine , however i have noticed that the instant redirect is causing browsers to skip the index.html file ,, there is nothing in my index.hmtl file that my users need to see but it contains my keywords/title/description tags .. although my users do not need this information ,, search engines DO so i was wondering if there is a line i can add to my .htaccess file that will force browsers to aknowledge the index.html file before it redirects...

PS: <meta refesh> and javascript redirects are NOT an option for me

PPS:Sorry for the long post but this is driving me mad.

[edited by: jdMorgan at 8:17 pm (utc) on July 26, 2004]

Birdman

6:20 pm on Jul 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld!

I imagine you need to write a server-side script to "cloak" you page. It basically keeps a list of search engine user agents and if it is a SE, it serves the index. Otherwise, it redirects to portal.

Birdman

bhartzer

6:29 pm on Jul 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Look at your http.conf file. There's a setting in there somewhere that lets you specify which file is served when someone goes to the home page of the domain. You can remove the index.html there and make it portal.php or whatever you want it to be.

Philosopher

6:51 pm on Jul 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep...you really only have the two options mentioned above. You either need to replace the index page with your portal page as the "homepage" of your site, or you will need to cloak.

If you cloak, remember that you are going against the TOS of the SE's (may not matter, may not mean anything), but you will be serving different content to humans and spiders.

Well...I guess you have a third option.

If you are not wanting to take the risk of cloaking or replace your index page with your portal page, you may want to consider removing the redirect and keeping the index page and simply allowing your visitors to click on a link to be taken to the portal page.

encyclo

6:59 pm on Jul 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, TanagerDave!

Surely it would be much easier to set portal.php as the directory index, meaning that it will be loaded by default when you go to your home page. If there are other directories on the site where you are using a standard index.php or index.htm file, then you can just specify them afterwards in the directive:

DirectoryIndex portal.php index.php index.htm

Otherwise, if there is no index.php in the document root, then you can just create the file with nothing but a 301 Permanent Redirect to portal.php.

<?php 
header("HTTP/1.1 301 Moved Permanently");
header("Location: portal.php");
exit;
?>

Much better than messing with mod_rewrite or RedirectMatch, which are overkill for this situation.

You should add your titles and keywords to your portal.php page and forget the old index page, which is functioning as a kind of "doorway" page and is a good way to get you banned.

Birdman

7:05 pm on Jul 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



DirectoryIndex is most definately the way to force a file to be shown, but I think Dave is looking to serve the engines a different file.

there is nothing in my index.hmtl file that my users need to see but it contains my keywords/title/description tags ..

although my users do not need this information , search engines DO so i was wondering if there is a line i can add to my .htaccess file that will force browsers to aknowledge the index.html file before it redirects...

Either way you decide to do it, it will be against the TOS of the engines but that's the risk you take, eh?

Me, I'll stick to the rules and actually put the keywords and stuff on the page that the users sees, whether they 'need' it or not. If it's relevant text, why not include it. If it's not relevant and you do include it, you're trying to cheat the system and therefore are taking a risk.