homepage Welcome to WebmasterWorld Guest from 54.167.10.244
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Logs incorrect URL
member22




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

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

Incorrect URL:
http://www.example.com/type/subtype/product/index.php

Correct URL:
http://www.example.com/type/subtype/product.html


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,
please?

 

lucy24




msg:4654007
 12:05 pm on Mar 14, 2014 (gmt 0)

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
^(([^/]+/)+)index\.php
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?

g1smd




msg:4654045
 1:52 pm on Mar 14, 2014 (gmt 0)

You could also redirect bare folder URL requests.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved