Forum: NGINX converting apache rewrites to nginx

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.
Ab608a1192d2c6f446e4042971daba8c?d=identicon&s=25 Andrew Thornton (Guest)
on 2009-01-04 21:09
(Received via mailing list)
Hello,

I am currently trying to get a deployment ready in an attempt to migrate
my
wiki from apache to nginx and php-fpm. Things have gone pretty smoothly
so
far, but I am having a real problem with rewrite rules. Here is what is
currently in my apache config for a rewrite:

<Directory "/var/www/ws/wiki">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?title=$1 [PT,L,QSA]
RewriteRule ^(images|skins)\/(.*)$ http://images.testsite.com/$1/$2 [L]
</Directory>

I have tried adding this a couple of different ways into the nginx
config
file but it isn't working. Can someone give me a hand with this? Also,
where
can I find docs on the rewrite functionality within nginx?

I appreciate any and all help,

Andrew
2c6f80fff253635f12c249ef4f116796?d=identicon&s=25 Jim Ohlstein (Guest)
on 2009-01-04 21:37
(Received via mailing list)
See http://wiki.codemongers.com/NginxHttpRewriteModule.







Assuming your doc root is /var/www/ws, try





location /wiki/ {



if (!-e $request_filename) {

rewrite ^/(.*)$ /index.php?title=$1 last;

}



rewrite ^/(images|skins)\/(.*)$ http://images.testsite.com/$1/$2  last;



}







You may need to add a forward slash in front of http in the second line.





Good luck,



Jim







From: owner-nginx@sysoev.ru [mailto:owner-nginx@sysoev.ru] On Behalf Of
Andrew Thornton
Sent: Sunday, January 04, 2009 3:01 PM
To: nginx@sysoev.ru
Subject: converting apache rewrites to nginx



Hello,

I am currently trying to get a deployment ready in an attempt to migrate
my
wiki from apache to nginx and php-fpm. Things have gone pretty smoothly
so
far, but I am having a real problem with rewrite rules. Here is what is
currently in my apache config for a rewrite:

<Directory "/var/www/ws/wiki">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?title=$1 [PT,L,QSA]
RewriteRule ^(images|skins)\/(.*)$ http://images.testsite.com/$1/$2 [L]
</Directory>

I have tried adding this a couple of different ways into the nginx
config
file but it isn't working. Can someone give me a hand with this? Also,
where
can I find docs on the rewrite functionality within nginx?

I appreciate any and all help,

Andrew
Ab608a1192d2c6f446e4042971daba8c?d=identicon&s=25 Andrew Thornton (Guest)
on 2009-01-04 22:48
(Received via mailing list)
Hey Jim,

Thanks for the link and for the advice. It worked great.

Thanks again
This topic is locked and can not be replied to.