Forum Moderators: phranque

Message Too Old, No Replies

Redirecting question mark

How do I redirect index.php? to index.php

         

motorhaven

4:12 pm on Oct 18, 2005 (gmt 0)

10+ Year Member Top Contributors Of The Month



We have forum software that for various reasons presents the main index page three ways:

/forums/index.php
/forums/index.php?
/forums/

Each one of those has different page rank with Google. I think we're getting some page rank dillution because of this.

I already have /forums/ redirecting to /forums/index.php but I can't figure out how to redirect index.php? to index.php.

I need do this without redirection things such as index.php?parameter=#*$!x to index.php, only redirecting index.php? to index.php.

jd01

7:55 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You will need to use a query_string OR the_request condition.

RewriteCond %{THE_REQUEST} forums/index.php\?\
RewriteRule ^forums/index.php$ /forums/index.php [R=301,L]

The above will redirect a blank query_string.

There is some more information in the Apache Library [webmasterworld.com] and Forum Charter [webmasterworld.com]. I will try to add some information on conditions soon.

Hope this helps.

Justin

motorhaven

9:23 pm on Oct 18, 2005 (gmt 0)

10+ Year Member Top Contributors Of The Month



Doesn't work. I've tried many simplier redirect, redirectmatch and rewrite variations and none seem to work. I'm wondering if Apache doesn't escape the? character correctly?

motorhaven

10:04 pm on Oct 18, 2005 (gmt 0)

10+ Year Member Top Contributors Of The Month



I've given up. I've even tried using \x3f to match it, still no dice.

I've just coded it into the index.php file to look for this condition and do a permanent redirect via PHP. Works like a charm, but I really wished I could have done it via Apache.

jdMorgan

10:32 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd suggest a few minor tweaks:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /forums/index\.php\?\ HTTP/
RewriteRule ^forums/index\.php$ /forums/index.php [R=301,L]

Jim