开发者

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

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 us开发者_开发技巧ing 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.


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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜