How do I write h2o webserver mruby handlers for WordPress multisite?
Asked Answered
M

1

9

This is what Apache needs. I like to know how I do this in h2o.

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

// wasted 300 reputation on this btw.

Merger answered 1/9, 2016 at 13:42 Comment(6)
did you read the comments on that issues thread? The suggestions seem to be rewrite using mruby instead of h20Melanite
@maxpleaner Can you read? Read the question again. There is no "instead of". I am well aware you have have to write complicated handlers like this in mruby thats why I am asking this question-because I do not speak ruby or mruby.Merger
ok but the maintainers said it's not possible.Melanite
@maxpleaner What? Where? You really seem trouble understanding. For sure its possible.Merger
the second comment on the issues thread.Melanite
So you speak about this comment? github.com/h2o/h2o/issues/604#issuecomment-159385193. Then no he did not at all say it's not possible.Merger
S
-1

Basically, your Apache file is a bit too much for WordPress.

This should do the trick on H2O:

hosts:
  "www.example.com":
    listen:
      port: 80
    paths:
      "/":
        file.dir: /path/to/doc-root   # serve static files if found
        redirect:                     # if not found, internally redirect to /index.php/<path>
          url: /index.php/
          internal: YES
          status: 307

file.custom-handler:                  # handle PHP scripts using php-cgi (FastCGI mode)
  extension: .php
  fastcgi.spawn: "PHP_FCGI_CHILDREN=10 exec /usr/bin/php-cgi"

access-log: /path/to/the/access-log
error-log: /path/to/the/error-log
pid-file: /path/to/the/pid-file
http2-reprioritize-blocking-assets: ON   # performance tuning option

Hope this helps...

Stalactite answered 3/10, 2017 at 9:49 Comment(2)
I think you totally failed to understand my question. I did not ask about a very basic server config. I specifically asked about rewrite rules. How is this helping? Also as a sidenote, I do not know why the h2o wiki shows a PHP-CGI config as a WordPress config. I use a different config to use PHP-FPM. To me it makes no sense to use a high performance server to then use a slower PHP solution. AFAIK PHP-FPM ist faster.Merger
"Basically, your Apache file is a bit too much for WordPress." seriously if you have no clue what you are talking about then don't answer questions. I asked for mruby code. Either way WordPress never interprets server config files so your "to much for WP" notion is total BS! I really have a hard time trying to understand how you can give such a crappy answer. You think I put the .htaccess code into me h2o.conf? And you think the multisite rewriting just simply works like magic without any config?I did not try to switch to FastCGI (use your config) because I am pretty sure there is no pointMerger

© 2022 - 2024 — McMap. All rights reserved.