Forum: NGINX rewrite help for w2box

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2974d09ac2541e892966b762aad84943?d=identicon&s=25 lblasc (Guest)
on 2009-05-14 12:49
(Received via mailing list)
Hello,

No luck with rewrite for w2box. Can I get some help with this ?

apache .htaccess :

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ index.php?d=$1&BAD_HOSTING=%{HTTP:Authorization}

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} ^(.+)$
RewriteRule ^(.*)$ index.php?%1&d=$1&BAD_HOSTING=%{HTTP:Authorization}

RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule (.+).php $1.php?%1&BAD_HOSTING=%{HTTP:Authorization}

Thanks !

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,2018,2018#msg-2018
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-05-14 13:29
(Received via mailing list)
On Thu, May 14, 2009 at 06:38:48AM -0400, lblasc wrote:

> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{QUERY_STRING} ^(.+)$
> RewriteRule ^(.*)$ index.php?%1&d=$1&BAD_HOSTING=%{HTTP:Authorization}
>
> RewriteCond %{QUERY_STRING} ^(.*)$
> RewriteRule (.+).php $1.php?%1&BAD_HOSTING=%{HTTP:Authorization}

It's a sealed book to me why w2box developers moved this query string
logic from PHP reach scripting to ugly RewriteRules.

If you use fastcgi, you may try:

server {

  ....

  if ($args) {
      set $args  $args&;
  }

  location / {
      try_files  $uri  $uri/ /index.php?${args}d=$uri;
  }

  location ~ \.php$ {
      try_files  $uri  $uri/ /index.php?${args}d=$uri;

      fastcgi_pass     ...;
      fastcgi_param    QUERY_STRING
${args}&BAD_HOSTING=$http_authorization;
      ...
  }

  location = /index.php {
      fastcgi_pass     ...;
      fastcgi_param    QUERY_STRING
${args}&BAD_HOSTING=$http_authorization;
      ...
  }
This topic is locked and can not be replied to.