[resolved] mod_rewrite gurus, help with max internal redirects error from MT permalinks (8 posts)

  1. relaxedguy
    Posted 8 years ago #

    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$ http://example.com/archives/$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.

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

  3. relaxedguy
    Posted 8 years ago #

    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.

  4. 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.

  5. netvista
    Posted 8 years ago #

    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:


  6. 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.

  7. AskApache
    Posted 8 years ago #

    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$ http://example.com/archives/$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 :)

  8. relaxedguy
    Posted 8 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic