Rewrites

Rewrites

Found a rewrite loop issue for subfolder installs - my explanation on the ticket. Basically if a file under wp-content is requested and not found, Apache goes into a rewrite loop.

Anyone with MU or a 3.0 network can fix their .htaccess files.

Existing rewrite rule you may have in 3.0:

RewriteRule (^[_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule (^[_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]

Or if you upgraded from MU it looks like this:
RewriteRule (^[_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule (^[_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]

Fixed version:

RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]

Just do a straight up replace of those lines.

If you have a subdomain install, you do not need to do this. If you have these rules, you can actually remove them.

13 Comments
  • Ipstenu
    Posted at 14:41h, 18 October Reply

    Interesting. I have :

    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]

    Will this cover that as well or should I leave the first line alone?

  • Ovidiu
    Posted at 05:53h, 19 October Reply

    great coincidence: installed my first sub folder wp installation yesterday with multisite and ran into a couple of endless redirects 🙂
    Hope this fixes it!

  • Kim
    Posted at 15:24h, 19 October Reply

    I’ve got one subfolder install – haven’t run into this issue yet, but already changed the rewrite rules with your recommendation. Thanks! 🙂

  • BayouGirl
    Posted at 09:10h, 29 November Reply

    Hey Andrea,

    Found myself here after trying to change themes to individual site…(you’ll find that I just left a comment on another post)….

    Attempted the fix, but nothing happened…

    I have 13 different sites that I tried to set up, but when I visit my dashboard under “My Sites” only the main blog shows up….what’s the deal with that…

    Am I missing something?

    Hope you can help me….

    Thanks

  • Craig Shrimpton
    Posted at 00:26h, 05 January Reply

    Actually I had to do this for a subdomain site. One of my blogs was generating an infinite loop and changing the rewrite fixed it.

    Doesn’t seem to have any negative impact.

  • James
    Posted at 19:31h, 26 September Reply

    I have setup subfolder redirect on dreamhost with mirrored domains.

    When I go to urew.com/ranch without the domain set as primary in the domains settings, then it loads correctly.
    If I go to ranch.com it will load urew.com/ranch.

    BUT once I select the primary domain button, they point to each other and get caught in a loop. I have looked at my .htaccess file and everything looks good there.

    If I load urew.com/ranch it tries to load ranch.com and then gets caught in the loop.
    If I load ranch.com, it gets caught in a loop.

    I have read tutorials and suggestions all afternoon. Any suggestions would be VERY appreciated.

    Thanks,
    James

  • Ron
    Posted at 21:03h, 26 September Reply

    they point to each other and get caught in a loop

    That’s exactly your problem. Remove the subfolder redirect in your hosting account then they won’t point at each other..

  • James
    Posted at 23:41h, 26 September Reply

    Ron,
    Thanks for the feedback. I actually have newharmonyranch.com pointing (mirrored) to ultimaterealestatewebsites.com. Then domain mapper makes it point to the right directory.

    Right now I have “primary” off, so it is just a simple redirect. If I turn “primary” on, then I get stuck in the loop.

    Is this what you were referring to? Or is there something else I am missing?

    • Ron
      Posted at 09:58h, 27 September Reply

      You do not need to point the domain to the folder, just point the domain to the WP install and domain mapping will handle the rest.

  • James
    Posted at 12:47h, 27 September Reply

    So I have my domain pointed to the domain where the wp install is. In this case ultimaterealestatewebsites.com

    The only thing I can figure out is that it may have something to do with dreamhost not allowing the wildcard in the DNS settings.

    I have newharmonyranch.com set as “mirrored” to ultimaterealestatewebsites.com without specifying a directory.

    As it is, there is basically a redirect setup. When I active the “primary” button on the domain mapping, then I get the loop.

    Thanks for your help.

    • andrea
      Posted at 17:44h, 02 October Reply

      you can map domains without the wildcard subdomain. that part is unrelated.

      ” have newharmonyranch.com set as “mirrored” to ultimaterealestatewebsites.com without specifying a directory.”

      and that’s why it doen;t work. gotta tell it where to go.

      I covered this in my domain mapping ebook.

  • James
    Posted at 12:54h, 27 September Reply

    I just tested another configuration.

    IF I have EITHER “primary” unchecked OR no value in the IP number field under domain settings THEN newharmonyranch.com works as a redirect.

    If primary is checked AND the IP address is filled in THEN we get caught in the loop.

    Thanks, James

    • Ron
      Posted at 22:21h, 28 September Reply

      The IP address is only there for user reference (ie. if you had users like wordpress.com who were mapping their own domains).

      The domain mapping plugin doesn’t use the IP address for anything.

      You’ll have to talk to dreamhost support about your configuration. What you are looking for is a server alias.

Post A Comment