Rewrite rule help

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Rewrite rule help

Anoop Alias
Hello,

It would be great if someone can help me port the following apache rewrite rules to nginx

=====================
RewriteRule @^/paOS(.+)@i /?/paos$1 [L]
RewriteRule ^SOap(.+) /?/paos$1 [L]
RewriteRule ^paos(.+) /?/paos$1 [L]

=====================

Thanks in advance

--
Anoop P Alias (PGP Key ID : 0x014F9953)
GNU system administrator
http://GnuSys.net
Reply | Threaded
Open this post in threaded view
|

Re: Rewrite rule help

Igor Sysoev
On Fri, May 29, 2009 at 11:24:36AM +0530, Anoop Alias wrote:

> Hello,
>
> It would be great if someone can help me port the following apache rewrite
> rules to nginx
>
> =====================
> RewriteRule @^/paOS(.+)@i /?/paos$1 [L]
> RewriteRule ^SOap(.+) /?/paos$1 [L]
> RewriteRule ^paos(.+) /?/paos$1 [L]
>
> =====================

I did not find @..@i syntax in mod_rewrite documntation, but it seems
it should case insensitive regex.

What should be done with /?/paos.... then ?


--
Igor Sysoev
http://sysoev.ru/en/

Reply | Threaded
Open this post in threaded view
|

Re: Rewrite rule help

Anoop Alias
Thank you Igor,

Sorry , that was the wrong apache rewrite rules

The correct one is
==================
RewriteRule ^(/paos|/soap)(.+) / [NC,L,PT]
==================

This is the one that needs to be ported to nginx fomat



Thanks again,

--
Anoop P Alias (PGP Key ID : 0x014F9953)
GNU system administrator
http://GnuSys.net
Reply | Threaded
Open this post in threaded view
|

Re: Rewrite rule help

Igor Sysoev
On Sat, May 30, 2009 at 07:21:06AM +0530, Anoop Alias wrote:

> Thank you Igor,
>
> Sorry , that was the wrong apache rewrite rules
>
> The correct one is
> ==================
> RewriteRule ^(/paos|/soap)(.+) / [NC,L,PT]
> ==================
>
> This is the one that needs to be ported to nginx fomat

location /paos/ {
    proxy_pass  http://backend/;
}

location /soap/ {
    proxy_pass  http://backend/;
}


--
Igor Sysoev
http://sysoev.ru/en/

Reply | Threaded
Open this post in threaded view
|

Re: Rewrite rule help

Anoop Alias
Thanks Igor,

But that does not work :(.

from what i could find out; i think the URL parsing is handled by the index.php file itself. so every request to a non existing content must pass to the index.php file without having any change in the URL. I guess that is why the apache pass through directive is there (PT). If we delete the PT the website stops functioning!


I found the following rules working correctly for lightppd

======================
           "^/paOScore(.+)$" => "/?/paoscore/$1",
                "^/paOS(.+)$" => "/?/paos$1",
                "^/SOap(.+)$" => "/?/paos$1",
======================

On similar lines the following nginx rules were created
======================
        rewrite ^/paOScore(.*)$         /?/paoscore/$1  last;

        rewrite ^/paOS(.*)$             /?/paos$1       last;
        rewrite ^/SOap(.*)$             /?/paos$1       last;
========================

Which works but gets the page in a redirect loop if an https page is requested.it works perfect for the http page

The URL's are all in the format

http://www.domain.com/paos-14-71-1h-49-en.html

http://www.domain.com/paoscore/10-49-en.html


The content is dynamically pulled from a database according to the URL input ;as far as i can see ;this is how it works

there is code snippets in the index.php which says
if ( $_SERVER[ 'REQUEST_URI' ]...
....

etc

any help is much appreciated

Thanks ,
Anoop


2009/5/30 Igor Sysoev <[hidden email]>
On Sat, May 30, 2009 at 07:21:06AM +0530, Anoop Alias wrote:

> Thank you Igor,
>
> Sorry , that was the wrong apache rewrite rules
>
> The correct one is
> ==================
> RewriteRule ^(/paos|/soap)(.+) / [NC,L,PT]
> ==================
>
> This is the one that needs to be ported to nginx fomat

location /paos/ {
   proxy_pass  http://backend/;
}

location /soap/ {
   proxy_pass  http://backend/;
}


--
Igor Sysoev
http://sysoev.ru/en/




--
Anoop P Alias (PGP Key ID : 0x014F9953)
GNU system administrator
http://GnuSys.net
Reply | Threaded
Open this post in threaded view
|

Re: Rewrite rule help

Anoop Alias
In short as far as i can tell, what is required is a method to pass all request to any non existing file to the index.php keeping the REQUEST_URI intact.
Now i maybe wrong also ; but i couldnt find anything in apache or lighttpd that says  replacement string has something passed as an argument


Thanks,
Anoop

--
Anoop P Alias (PGP Key ID : 0x014F9953)
GNU system administrator
http://GnuSys.net