[Cherokee] Wordpress and url rewrite

306 views
Skip to first unread message

Antonio Pérez

unread,
Sep 5, 2008, 1:00:50 PM9/5/08
to cher...@lists.octality.com
Hi!

Anyone could help me with this .htaccess file?

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

I'm trying to use my custom permalinks in Wordpress and I need to
"emulate" this behaviour in Cherokee.

Thanks in advance!.

--
Saludos:
Antonio Pérez

ATENCIÓN: Antes de imprimir este mensaje valora si verdaderamente es necesario.
De esta forma contribuimos a la preservación del Medio Ambiente.
_______________________________________________
Cherokee mailing list
Cher...@lists.octality.com
http://lists.octality.com/listinfo/cherokee

Miguel Ángel

unread,
Sep 5, 2008, 1:56:22 PM9/5/08
to Antonio Pérez, cher...@lists.octality.com
I need it too :) I still have it on my pending tasks ':)

Miguel Ángel

El 05/09/2008, a las 19:00, "Antonio Pérez" <apli...@skarcha.com>
escribió:

Alvaro Lopez Ortega

unread,
Sep 5, 2008, 2:15:15 PM9/5/08
to Miguel Ángel, cher...@lists.octality.com
Miguel Ángel wrote:

> I need it too :) I still have it on my pending tasks ':)

Guys, I'm pretty sure you are gonna love the new 'wizards' feature
shipped with the upcoming Cherokee 0.9 :-)

> El 05/09/2008, a las 19:00, "Antonio Pérez" <apli...@skarcha.com>
> escribió:
>
>> Hi!
>>
>> Anyone could help me with this .htaccess file?
>>
>> <IfModule mod_rewrite.c>
>> RewriteEngine On
>> RewriteBase /
>> RewriteCond %{REQUEST_FILENAME} !-f
>> RewriteCond %{REQUEST_FILENAME} !-d
>> RewriteRule . /index.php [L]
>> </IfModule>
>>
>> I'm trying to use my custom permalinks in Wordpress and I need to
>> "emulate" this behaviour in Cherokee.

This is something you can configure with the "Behavior" section of your
Virtual Server.

It first look, I'd say that something like this could be enough:

- Extension php "FastCGI"
- Directory /images "Static content"
- Directory /bla, bla "Static content"
- Directory /lalala "Static content"
- Default ^.+$ "Redirection" (to /index.php?$1)

Good luck!

--
Greetings, alo
http://www.alobbs.com/

Antonio Pérez

unread,
Sep 5, 2008, 2:22:35 PM9/5/08
to Alvaro Lopez Ortega, cher...@lists.octality.com
On Fri, Sep 5, 2008 at 8:15 PM, Alvaro Lopez Ortega <alv...@alobbs.com> wrote:

>> I need it too :) I still have it on my pending tasks ':)
>
> Guys, I'm pretty sure you are gonna love the new 'wizards' feature shipped
> with the upcoming Cherokee 0.9 :-)

I hope!, I hope!... :D

>>> I'm trying to use my custom permalinks in Wordpress and I need to
>>> "emulate" this behaviour in Cherokee.
>
> This is something you can configure with the "Behavior" section of your
> Virtual Server.
>
> It first look, I'd say that something like this could be enough:
>
> - Extension php "FastCGI"
> - Directory /images "Static content"
> - Directory /bla, bla "Static content"
> - Directory /lalala "Static content"
> - Default ^.+$ "Redirection" (to /index.php?$1)

Ufff!

But this need to add rules every time I create a new directory, or file in "/".

I think the problem here is how to get those rewrite conditions works
on Cherokee.

> Good luck!

Anyway, it's a good hack at the moment... Thanks for your help. ;)


--
Saludos:
Antonio Pérez

ATENCIÓN: Antes de imprimir este mensaje valora si verdaderamente es necesario.
De esta forma contribuimos a la preservación del Medio Ambiente.

Antonio Pérez

unread,
Sep 5, 2008, 3:06:47 PM9/5/08
to Alvaro Lopez Ortega, cher...@lists.octality.com
On Fri, Sep 5, 2008 at 8:15 PM, Alvaro Lopez Ortega <alv...@alobbs.com> wrote:

> - Extension php "FastCGI"
> - Directory /images "Static content"
> - Directory /bla, bla "Static content"
> - Directory /lalala "Static content"
> - Default ^.+$ "Redirection" (to /index.php?$1)

First problem... WordPress use PATH_INFO, so redirection must be:
"/index.php$1", and Cherokee doesn't recognize it as an .php extension
file, so it enters in a loop.


--
Saludos:
Antonio Pérez

ATENCIÓN: Antes de imprimir este mensaje valora si verdaderamente es necesario.
De esta forma contribuimos a la preservación del Medio Ambiente.

Miguel Ángel

unread,
Sep 5, 2008, 5:23:14 PM9/5/08
to Antonio Pérez, cher...@lists.octality.com, Alvaro Lopez Ortega
Hi :)
the problem on these rules, as antonio says, is that wordpress
creates file irks dinamically. I'm not sure about worspress but that
happened to me with wordpress mu.

I think that some rewrite rules could be only translates if we
get those kind of conditionals: "-f" it's not a file, and "-d" it's
not a directory . Other way could be putting the static files as first
rules and leting it fallback on the rewrite when the file doesn't exist.


Miguel Ángel

El 05/09/2008, a las 20:22, "Antonio Pérez" <apli...@skarcha.com>
escribió:

Alvaro Lopez Ortega

unread,
Sep 6, 2008, 5:09:55 AM9/6/08
to Antonio Pérez, cher...@lists.octality.com
Antonio Pérez wrote:
> On Fri, Sep 5, 2008 at 8:15 PM, Alvaro Lopez Ortega <alv...@alobbs.com> wrote:
>>>> I'm trying to use my custom permalinks in Wordpress and I need to
>>>> "emulate" this behaviour in Cherokee.
>> This is something you can configure with the "Behavior" section of your
>> Virtual Server.
>>
>> It first look, I'd say that something like this could be enough:
>>
>> - Extension php "FastCGI"
>> - Directory /images "Static content"
>> - Directory /bla, bla "Static content"
>> - Directory /lalala "Static content"
>> - Default ^.+$ "Redirection" (to /index.php?$1)
>
> Ufff!
>
> But this need to add rules every time I create a new directory, or file in "/".

No. That means that you would have to add a new rule whenever you create
a new directory *within your blog directory* (or virtual server).. which
should be certainly something very unusual.

> I think the problem here is how to get those rewrite conditions works
> on Cherokee.

That is not going to happen unless a really good reason comes up. That
is one of those approaches that makes web servers run so slow.

I don't think that you will have to add more of three of four rules to
configure the whole Wordpress thing, so assuming a performance penalty
for saving a couple of rules does not really make sense to me.

Think of it in this way: You spend 15 secs adding the rule, and your
server will run faster during the next N years. It does sound like a
good time inversion, doesn't it?

>> Good luck!
>
> Anyway, it's a good hack at the moment... Thanks for your help. ;)

Independently of whether we could kind of hide it behind a wizard, it is
the way it has been designed to work. There is neither 'hacks' or
'work-arounds' involved on this.

Keep in mind that there are alternative ways of doing things. It does
not matter whether any other web server works in the same way or not.
We are making independent decisions, and that is one of the reasons why
Cherokee is currently outperforming all the rest.

--
Greetings, alo
http://www.alobbs.com/

Alvaro Lopez Ortega

unread,
Sep 6, 2008, 5:18:05 AM9/6/08
to Antonio Pérez, cher...@lists.octality.com
Antonio Pérez wrote:
> On Fri, Sep 5, 2008 at 8:15 PM, Alvaro Lopez Ortega <alv...@alobbs.com> wrote:
>
>> - Extension php "FastCGI"
>> - Directory /images "Static content"
>> - Directory /bla, bla "Static content"
>> - Directory /lalala "Static content"
>> - Default ^.+$ "Redirection" (to /index.php?$1)
>
> First problem... WordPress use PATH_INFO, so redirection must be:
> "/index.php$1", and Cherokee doesn't recognize it as an .php extension
> file, so it enters in a loop.

It depends on your configuration whether Cherokee detects the php
extension or not.

Anyway, a few days ago Rui found a bug that might be hitting you with
this. It's related to how the PATH_INFO string is generated. I will get
back to you guys as soon as I fix it on Trunk (hopefully within the next
few days).

--
Greetings, alo
http://www.alobbs.com/

Antonio Pérez

unread,
Sep 6, 2008, 5:28:32 AM9/6/08
to Alvaro Lopez Ortega, cher...@lists.octality.com
On Sat, Sep 6, 2008 at 11:09 AM, Alvaro Lopez Ortega <alv...@gnu.org> wrote:

>> But this need to add rules every time I create a new directory, or file in
>> "/".
>
> No. That means that you would have to add a new rule whenever you create a
> new directory *within your blog directory* (or virtual server).. which
> should be certainly something very unusual.

Ok... it's true.

>> I think the problem here is how to get those rewrite conditions works
>> on Cherokee.
>
> That is not going to happen unless a really good reason comes up. That is
> one of those approaches that makes web servers run so slow.
>
> I don't think that you will have to add more of three of four rules to
> configure the whole Wordpress thing, so assuming a performance penalty for
> saving a couple of rules does not really make sense to me.
>
> Think of it in this way: You spend 15 secs adding the rule, and your server
> will run faster during the next N years. It does sound like a good time
> inversion, doesn't it?

I had not thought in this way... You are right. :)


--
Saludos:
Antonio Pérez

ATENCIÓN: Antes de imprimir este mensaje valora si verdaderamente es necesario.
De esta forma contribuimos a la preservación del Medio Ambiente.

Alvaro Lopez Ortega

unread,
Sep 6, 2008, 5:45:32 AM9/6/08
to Miguel Ángel, cher...@lists.octality.com
Miguel Ángel wrote:

> I think that some rewrite rules could be only translates if we get
> those kind of conditionals: "-f" it's not a file, and "-d" it's not a
> directory . Other way could be putting the static files as first rules
> and leting it fallback on the rewrite when the file doesn't exist.

Yes, that is exactly the way it is supposed to be configured.

If you add a couple of additional rules (for the -f, -d cases) you will
point the server something that otherwise it would have to recheck
millions of times on execution.

Adding those rules, you are spending a little time for getting an
interesting performance improvement.

--
Greetings, alo
http://www.alobbs.com/

Urko Masse

unread,
Aug 26, 2009, 9:22:14 PM8/26/09
to Miguel Ángel, cher...@lists.octality.com
So... Did anybody ever get Wordpress MU to work with Cherokee? :)

I'm trying to run it in a /blogs/ subfolder, not as a virtual server
in the root folder. Though I guess I could change that with some work.

Necesito ayuda! (I need help!)

On Sep 6 2008, 4:23 am, Miguel Ángel <miguelan...@ajo.es> wrote:
> Hi :)
>    the problem on these rules, as antonio says, is that wordpress  
> creates file irks dinamically. I'm not sure about worspress but that  
> happened to me with wordpress mu.
>
>      I think that some rewrite rules could be only translates if we  
> get those kind of conditionals: "-f" it's not a file, and "-d" it's  
> not a directory . Other way could be putting the static files as first  
> rules and leting it fallback on the rewrite when the file doesn't exist.
>
> Miguel Ángel
>

> El 05/09/2008, a las 20:22, "Antonio Pérez" <aplis...@skarcha.com>  

> Chero...@lists.octality.comhttp://lists.octality.com/listinfo/cherokee

Matt Austin

unread,
Aug 26, 2009, 10:52:35 PM8/26/09
to Urko Masse, cher...@lists.octality.com
I got Wordpress MU working a while ago (as a test/demo only) using URL
paths, rather than subdomains...

Permalinks in Wordpress MU are set as the custom:
/index.php/%year%/%monthnum%/%postname%/

This worked, but it is complicated, and may be over-the-top (can't
remember too much)...


Behaviour Rules
1)
Complex: (Not (File Exists: Any file)) AND (Regular Expression:
^/([_0-9a-zA-Z-]+)/(wp-.*|.*\.php(\?.*|))$)
Handler Internal Redirection: ^/([_0-9a-zA-Z-]+)/(wp-.*)$ to
^/([_0-9a-zA-Z-]+/)/(.*\.php(\?.*|))$
Handler Internal Redirection: ^/([_0-9a-zA-Z-]+/)/(.*\.php(\?.*|))$ to /$2

2)
Regular Expression: ^(.*)\.php(\?.*|)$
Handler: FastCGI

3)
Complex: Not (File Exists: Any file)
Handler Internal Redirection: ^/(.*)$ to /index.php

3)
Default, List & Send


If you'd prefer me to take screenshots of the behaviour settings, then
just let me know :P


Cheers,

Matt.


2009/8/27 Urko Masse <urko....@gmail.com>

Urko Masse

unread,
Aug 26, 2009, 11:38:38 PM8/26/09
to Matt Austin, cher...@lists.octality.com
Hi,

I think I get what you mean, so I'll give it a try later. It will take me a while, though, because this time I'll do it on a separate server that I need to finish setting up.

If you feel like doing screenshots in the mean time, I'd really REALLY appreciate it, though :)
Would give me far better chances to get it done right the first time!

Thanks for your great help!

2009/8/27 Matt Austin <ma...@mattaustin.me.uk>

Matt Austin

unread,
Aug 27, 2009, 2:06:15 AM8/27/09
to Urko Masse, cher...@lists.octality.com
I uploaded some screenshots:
http://mattaustin.me.uk/wordpress-mu-cherokee.tar.gz

You'll still want to reference my previous email, as some of the
regular expressions are cut short in the screenshots as they are
longer than the input text box.


Cheers,

Matt.

Urko Masse

unread,
Aug 27, 2009, 2:10:16 AM8/27/09
to Matt Austin, cher...@lists.octality.com
Thanks a LOT!!! :) I'll give it a try and report back.
--
Urko Masse
+84-90-9088876

Stephen Leacock  - "I detest life-insurance agents: they always argue that I shall some day die, which is not so."

Urko Masse

unread,
Aug 28, 2009, 6:19:43 AM8/28/09
to Matt Austin, cher...@lists.octality.com
Hi there,

I got it to work, at least in a test server. My setup is slightly different than yours, so I had to adjust the regular expressions a bit, also to prevent conflicts with the other stuff on the server. My WPMU is installed in a /blogs/ subfolder.

Cherokee and Wordpress MU (WPMU):

3 rules need to be added to be processed before any others:

1 - Rule Type: Complex:
  • Rule:
    • Regular Expression: ^/blogs/([_0-9a-zA-Z-]+)/(wp-.*|.*\.php(\?.*|))$ AND
    • Not ( File Exists, Match any file, disabled all the other checkboxes )
  • Handler: Redirection, 2 lines:
    • Type Internal, Regular Expression: ^/blogs/([_0-9a-zA-Z-]+)/(wp-.*)$ to Substitution: /blogs/$2
    • Type Internal, Regular Expression: ^/blogs/([_0-9a-zA-Z-]+/)/(.*\.php(\?.*|))$ to Substitution: /blogs/$2
2 - Rule Type: Regular Expression:
  • Rule:
    • Regular Expression: ^/blogs/(.*)\.php(\?.*|)$
  • Handler:
    • FastCGI, Information source: PHP Interpreter. All options left as default.
3 - Rule Type: Complex
  • Rule:
    • Regular Expression: ^/blogs(.*)$ AND
    • NOT ( File Exists, Match any file, disabled all the other checkboxes )
  • Handler:
    • Redirection: Internal, Regular Expression: ^/blogs/(.*)$ to Substitution: /blogs/index.php

Changes compared to the initial suggestion
I have placed the Regular Expression part of the "AND" Complex Rules first, from my programming experience that would hopefully be faster than hitting the filesystem all the time, specially since I/O cache is disabled in the Not File Exists part. That is if Cherokee does shortcut evaluation of the rules (I hope it does!).

I had to make the 3rd rule complex, adding a Regular Expression to make sure it only got applied to the /blogs/ part of my server. This makes it possible to share the virtual server with other web apps.

I haven't done this in the production server yet, but I'll tackle it on Monday, as it's way past my time to go home :)
Any feedback?

Urko Masse

unread,
Aug 31, 2009, 2:43:14 AM8/31/09
to Matt Austin, cher...@lists.octality.com
Mmmm... I think I was doing the victory dance a bit too early. I'm having problems with embedded images.

Matt, I have noticed that the rules as you wrote them on your post are different from the screenshots you sent.

In particular, the first rule, the first handler, in your email, you said:
Handler Internal Redirection:
^/([_0-9a-zA-Z-]+)/(wp-.*)$ to ^/([_0-9a-zA-Z-]+/)/(.*\.php(\?.*|))$
(which I think is wrong, as I don't see any $1 or $2 in the substitution string)
And in your screenshot it was redirection to /$2.

Not sure if it was related, I'm just mentioning it.

In any case, I used /$2 (with /blogs before it). And everything works, except the embedded images. Which probably means that all the embedded content, uploaded to the local server, doesn't work either.

I wish I knew what is the proper, actual, after all redirection rules are applied in Apache, URLs that WPMU needs...

Any ideas are welcome.
--
Urko Masse
+84-90-9088876

Ted Turner  - "Sports is like a war without the killing."

Urko Masse

unread,
Aug 31, 2009, 6:03:54 AM8/31/09
to Matt Austin, cher...@lists.octality.com
Ok, figured it out. There is one more rule to add, in the first place, before all the rest, to handle the wp-content links.

Here is the updated "how-to":


Cherokee and Wordpress MU (WPMU):

4 rules need to be added to be processed before any others:

1 - Rule Type: Regular Expression:
  • Rule:
    • Regular Expression: ^/blogs/.*/files.*$
  • Handler: Redirection
    • Regular Expression: ^/blogs/(.*)/files/(.*) to Substitution: /blogs/wp-content/blogs.php?file=$2

2 - Rule Type: Complex:
  • Rule:
    • Regular Expression: ^/blogs/([_0-9a-zA-Z-]+)/(wp-.*|.*\.php(\?.*|))$ AND
    • Not ( File Exists, Match any file, disabled all the other checkboxes )
  • Handler: Redirection, 2 lines:
    • Type Internal, Regular Expression: ^/blogs/([_0-9a-zA-Z-]+)/(wp-.*)$ to Substitution: /blogs/$2
    • Type Internal, Regular Expression: ^/blogs/([_0-9a-zA-Z-]+/)/(.*\.php(\?.*|))$ to Substitution: /blogs/$2
3 - Rule Type: Regular Expression:

  • Rule:
    • Regular Expression: ^/blogs/(.*)\.php(\?.*|)$
  • Handler:
    • FastCGI, Information source: PHP Interpreter. All options left as default.
4 - Rule Type: Complex

  • Rule:
    • Regular Expression: ^/blogs(.*)$ AND
    • NOT ( File Exists, Match any file, disabled all the other checkboxes )
  • Handler:
    • Redirection: Internal, Regular Expression: ^/blogs/(.*)$ to Substitution: /blogs/index.php

Changes compared to the initial suggestion
I have placed the Regular Expression part of the "AND" Complex Rules first, from my programming experience that would hopefully be faster than hitting the filesystem all the time, specially since I/O cache is disabled in the Not File Exists part. That is if Cherokee does shortcut evaluation of the rules (I hope it does!).

Any feedback/suggestions?

Urko Masse

unread,
Aug 31, 2009, 6:19:13 AM8/31/09
to cher...@lists.octality.com
Sorry, I just detected 2 small errors:


Cherokee and Wordpress MU (WPMU):

4 rules need to be added to be processed before any others:

1 - Rule Type: Regular Expression:
  • Rule:
    • Regular Expression: ^/blogs/.*files.*$
  • Handler: Redirection
    • Regular Expression: ^/blogs/(.*)files/(.*) to Substitution: /blogs/wp-content/blogs.php?file=$2

2 - Rule Type: Complex:
  • Rule:
    • Regular Expression: ^/blogs/([_0-9a-zA-Z-]+)/(wp-.*|.*\.php(\?.*|))$ AND
    • Not ( File Exists, Match any file, disabled all the other checkboxes )
  • Handler: Redirection, 2 lines:
    • Type Internal, Regular Expression: ^/blogs/([_0-9a-zA-Z-]+)/(wp-.*)$ to Substitution: /blogs/$2
    • Type Internal, Regular Expression: ^/blogs/([_0-9a-zA-Z-]+)/(.*\.php(\?.*|))$ to Substitution: /blogs/$2
3 - Rule Type: Regular Expression:
  • Rule:
    • Regular Expression: ^/blogs/(.*)\.php(\?.*|)$
  • Handler:
    • FastCGI, Information source: PHP Interpreter. All options left as default.
4 - Rule Type: Complex
  • Rule:
    • Regular Expression: ^/blogs(.*)$ AND
    • NOT ( File Exists, Match any file, disabled all the other checkboxes )
  • Handler:
    • Redirection: Internal, Regular Expression: ^/blogs/(.*)$ to Substitution: /blogs/index.php

Notes:
This is for a WPMU installation in the subfolder "/blogs/". Adjust accordingly for your own installation.

Matt Austin

unread,
Aug 31, 2009, 7:22:09 AM8/31/09
to Urko Masse, cher...@lists.octality.com
Hi Urko,

I'm glad you got it sorted. I don't think I ever got as far as
uploading images when I installed it as a quick test!

Let me know if there is anything else I can help with though.

Cheers,

Matt.

Reply all
Reply to author
Forward
0 new messages