Support » Fixing WordPress » mod_rewrite gurus, help with max internal redirects error from MT permalinks

  • Resolved relaxedguy


    Calling all mod_rewrite gurus! I needed to remove the .php suffix and the day of the month from uri’s when I migrated my Movable type blog to wordpress.

    The following rule does exactly what I wanted in Apache 1.3.33, which is running on my Mac laptop, but fails with a 500 error at my host, which is running Apache 2.0.46.

    RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(.*)\.php$$1/$2/$4 [R]

    Someone said to add Options +FollowSymLinks, which didn’t help.

    Now the CSS is not downloaded and I get this:

    “mod_rewrite: maximum number of internal redirects reached”

    I am running a plug-in on WordPress that does a redirect which removes the www in front of my domain name. This could be an issue as well.

    Also, someone should revise the Version pulldown to reflect 2.1.2 when ading a new topic here.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Not certain, but try making that [R] into an [R,L]. Or possibly an [R=301,L].

    thanks Otto, I thought that the [L] represented the last rewrite rule?

    WordPress automagically places this in htaccess:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    bunch of rewrites
    RewriteRule . /index.php [L]

    I try to stick my RewriteRule in the middle because the last rule is index.php [L]

    My rewrite gets overwritten by WP since it’s in the code block. Even so, when it’s in there, it needs to go before the last rule?

    Getting closer, frustrating that it works on my laptop just fine.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    The L tells it where to stop processing the rewrite rules. An R with an L tells it to stop processing the rules and send back the redirect to the browser, redirecting the user to the new URL.

    the sollution is very simple add this into your .htaccess file:

    RewriteOptions MaxRedirects=xxx

    Where xxx is the number of redirects you want. You can read more about it here:

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    My rewrite gets overwritten by WP since it’s in the code block.

    Don’t put your rule into WordPress’ code block. Put it before WordPress’ code block.

    Options +FollowSymLinks
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(.*)\.php$$1/$2/$4 [R,L]
    RewriteCond %{REQUEST_URI} ^archives/.*$
    RewriteCond %{REQUEST_URI} !^.+\.php.*$
    RewriteRule .* - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    You need a loop-stopper.. the above code should be all you need 🙂

    Otto and cduke, thanks much for your help. my 404 log is much smaller now and seeing the automatic url change to the correct archive put a big smile on my face.

    I will continue to learn more about mod_rewrite, the perfect tutorial has been difficult to find.

    Consider this thread closed!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘mod_rewrite gurus, help with max internal redirects error from MT permalinks’ is closed to new replies.