Apache to nginx rewrite rule

Looking to do something like this:

RewriteRule ^youtube/(.*)$ http://www.youtube.com/$1 [L]

This the configuration I’m thinking of?

location /youtube/
{
rewrite ^(.*)$ http://www.youtube.com$1
}

On 29 Dez 2010 15h30 WET, [email protected] wrote:

[1 <multipart/alternative (7bit)>]
[1.1 <text/plain; ISO-8859-1 (7bit)>]
Looking to do something like this:

RewriteRule ^youtube/(.*)$ 1 - YouTube [L]

This the configuration I’m thinking of?

location /youtube/
^^^^^^^^^

This means that you have a location /youtube not a host (vhost)

{
rewrite ^(.*)$ http://www.youtube.com$1
}

You seem to be confusing host (server_name) with location. That type
of rewriting must be done at the server (virtual host) level.

Cf. Pitfalls and Common Mistakes | NGINX

— appa

Thanks, but no, I’m not confusing location with host name.

I’m trying to redirect any requests on our domain as follows:

https://www.ourdomain.com/youtube/v/mydjFYoD4WS&hl=en_US&fs=1&rel=0&autoplay=1

to:

This is to solve a SSL warning issue. We’re already doing it on another
site using the .htaccess rule I provided.

See: http://www.adammershon.com/display-youtube-videos-on-ssl-page/

for more specific information and example.

that worked, thanks

On 29 Dez 2010 17h04 WET, [email protected] wrote:

This is to solve a SSL warning issue. We’re already doing it on
another site using the .htaccess rule I provided.

See: http://www.adammershon.com/display-youtube-videos-on-ssl-page/

Try this:

location /youtube {
rewrite ^/youtube/(.*)$ http://wwww.youtube.com/$1 break;
}

— appa

On Wed, Dec 29, 2010 at 02:56:10PM -0500, Ilan B. wrote:

that worked, thanks

You do not need “break”.

location /youtube {
rewrite ^/youtube/(.*)$ http://wwww.youtube.com/$1;
}

This is enough.

nginx Info Page


nginx mailing list
[email protected]
nginx Info Page


Igor S.
http://sysoev.ru/en/

On 29 Dez 2010 19h59 WET, [email protected] wrote:

This is enough.
Yes. There’s no point in having a flag here, since the redirect is to
an external site, so no other location is tried for handling the
request. It exits immediately.

Thanks Igor,
— appa