homepage Welcome to WebmasterWorld Guest from 23.20.34.25
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
how to 301 all index pages
joergnw10




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

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




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

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




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

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

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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved