Welcome to WebmasterWorld Guest from 50.19.135.67

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Redirecting index.php to root, but no other index

     

madmatt69

5:20 pm on Oct 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

I've got a rewrite rule that will redirect www.mysite.com/index.php to www.mysite.com - works fine.

The problem I'm running into now is that I have a forum installed on my site where I need to login to the administration section, and it requires going to admin/index.php - and now the server redirects it to admin/ and so I get thrown into a loop where I can't login.

I've determined the code that is causing this is:


RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.mysite.com/$1 [R=301,L]

How can I make this play nice?

Thanks for any help

jdMorgan

5:57 pm on Oct 14, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Get rid of the ambiguous ".*" pattern, which matches anything, everything, or nothing at all:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(#[^?\ ]*)?(\?[^\ ]*)?\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/$1 [R=301,L]

Note that the extra bits at the end of the RewriteCond pattern allow for fragment identifiers (HTML named anchors) or query strings on "index.php", but do not allow a match on, for example, ".php5" or ".phpx".

Jim

madmatt69

6:21 pm on Oct 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's why you're awesome!

Worked like a charm, thanks :)

g1smd

8:51 pm on Oct 14, 2009 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Are there are any index file URLs in any other folders that should redirect but which now do not?

madmatt69

9:07 pm on Oct 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not that I can tell.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month