htaccess :

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Removes index.php from ExpressionEngine URLs
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]

    # Remove www.
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [L,R=301]

    RedirectMatch 301 /page_1 http://domain.com/segment_1/page_1
    RedirectMatch 301 /page_2 http://domain.com/segment_1/page_2
    RedirectMatch 301 /segment_1/page_x http://domain.com/segment_1/segment_2/page_x

The last redirect works but the first two don't. (Error infinite loop).

Anyone has an idea why?

  • 1
    First off, make sure you are testing by opening a fresh Private Browsing window (if you are using Chrome, or whatever your equivalent is). Most browsers cache 301 redirects (since they are supposed to be permanent), and this can display errors which may not actually exist. Mar 2, 2013 at 18:07
  • Your code is correct so I'd agree with Adrian that it's some type of caching causing the issue.
    – Anna_MediaGirl
    Mar 2, 2013 at 21:13
  • As a test, have you moved one of the non-working redirects to the last position?
    – Anna_MediaGirl
    Mar 2, 2013 at 21:14
  • Nah. It doesn't work. No matter if private browsing, different computer or clearing cache/ disable ce-cache. Is there another way of doing 301 redirects?
    – KSPR
    Mar 3, 2013 at 12:25

2 Answers 2


Okay, I found the error (If anyone's intrested):

I must not write RedirectMatch 301 instead I simply have to write Redirect. So simple.

  • 1
    RedirectMatch = "contains" and Redirect = "starts with" in the URI.
    – Nevin Lyne
    Apr 6, 2013 at 14:38

I normally serve my redirects before my removal of index.php

Here's an example I know to work http://d.pr/n/1rQO

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.