Need to make one RewriteRule play nicely with another, embarrassingly weak understanding of the principles of mod_rewrite standing in the way

I have the following system:

Windows Server ’03
IIS 6 (shoot me)
PHP 5.2.14
Wordpress 3.0.1
WPML 1.8.1.2

Read More

I’ve added WordPress to an existing high-traffic site, in a directory we’ll call

http://thehost/wordpress/

For mod_rewrite-like features, I’m using Helicon’s ISAPI_Rewrite 3.1.0.76. I’m using it to enable “pretty” permalinks in the WordPress install. The single rule is this:

RewriteRule ^/wordpress/(?!index.php)(?!wp)([^.]*)$ /wordpress/index.php/$1 [I,L]

I need to add another rule, however, and neither of my dual strategies of thinking it through and bashing it through has borne fruit.

My site is a fully bilingual one. There are no pages that aren’t under one of the two following subdirectories:

http://thehost/en/ for English, and

http://thehost/sp/ for Spanish.

This is a convention I aim to maintain, even for the WordPress install. I currently have a somewhat hacked version of WPML (WordPress Multilingual plugin) operating, and it works such that all pages and posts—regardless of the language—include either the /en/ or the /sp/ in the URL. This has led me to believe I am achingly close—perhaps only one RewriteRule away!—to making my WordPress URLs conform to the same URL convention as the rest of my site. My problem though, as described, is that I can’t quite get it to work.

So, if I have this URL somewhere in my WordPress install:

http://thehost/wordpress/en/2010/08/omg-this-post-is-in-english/

how can I transform it to

http://thehost/en/wordpress/2010/08/omg-this-post-is-in-english/

while not losing WordPress’s permalinks? I’ve managed to swap the /en/ to its correct location (^/en/wordpress/(.*) /wordpress/en/$1), but I can’t get the two rules to play nicely together. That’s my problem. Well, that and a few others not appropriate for stackoverflow.com.

Thanks for your time.

Related posts

Leave a Reply

1 comment

  1. Try chaining the rules with the “C” Flag. Example:

    RewriteRule ^/en/wordpress/(.*) /wordpress/en/$1 [C]
    RewriteRule ^/wordpress/(?!index.php)(?!wp)([^.]*)$ /wordpress/index.php/$1 [I,L]