Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Logs incorrect URL

10:46 am on Mar 14, 2014 (gmt 0)

Preferred Member

5+ Year Member

joined:Apr 29, 2008
posts: 624
votes: 0

I have seen some unwanted URL requests in my logs and I would like to
redirect them to the correct URL.

Incorrect URL:

Correct URL:

To redirect incorrect to the correct one, I thought of this:

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

I was going to put this after individual page redirects and just above
non-www to www redirect. Could anybody check if my syntax is correct,
12:05 pm on Mar 14, 2014 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
votes: 244

You don't need the part about "the request", since you're redirecting to an entirely different URL, not just away from a named index file. Is it a pattern? If so, it's

RewriteRule ^(list-of-exact-names-here|with-pipes-as-appropriate)/index\.php http://www.example.com/$1.html? [R=301,L]

The generic form goes

but at this point it's essential to know whether you also have directory index files that really are called "index.php". If you do, you obviously can't have a generic redirect or you'll inadvertently send those requests to the wrong place.

Is there any pattern to the wrong requests? For example, recurring filenames, or everything in a particular directory?
1:52 pm on Mar 14, 2014 (gmt 0)

Senior Member

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

joined:July 3, 2002
votes: 0

You could also redirect bare folder URL requests.