Welcome to WebmasterWorld Guest from 107.20.34.173

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

how to 301 all index pages

     

joergnw10

9:24 am on Aug 10, 2006 (gmt 0)

10+ Year Member



Thanks to the info in this forum I now have the following in my .htaccess file:

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

Is there something I can add so that all my index files are redirected to the directory level? i.e. http://www.example.com/folder1/index.php to http://www.example.com/folder1/?

I tried to do redirects for the single pages by adding lines like:
RewriteRule ^folder1/index.php http://www.example.com/folder1/ [R=301,L]

but when loading these pages it comes up with the message "redirection limit for this URL exceeded".

jdMorgan

1:43 pm on Aug 10, 2006 (gmt 0)

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



If I understand your question, this should do what you want, by accounting for possibile subdirectory path info ahead of "index.xyz":

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

Replace all broken pipe "¦" characters with a solid pipe before use; Posting on this forum modifies them.

Jim

joergnw10

4:38 pm on Aug 10, 2006 (gmt 0)

10+ Year Member



Thanks a lot, Jim. That is exactly what I was looking for!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month