Welcome! Log In Create A New Profile

Advanced

Convert rewrite from apache to nginx

Posted by asdfg 
Convert rewrite from apache to nginx
March 20, 2013 08:57AM
Hello,

I have this .htaccess file in my apache configuration:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.* - [L]

RewriteRule ^(.*)/(.*)_image.jpg http://example.com/page.html [L]
RewriteRule ^(.*)/(.*)_(.*).jpg http://example.com/page.html [L]

Can you please convert this rules to nginx? Thanks.



Edited 1 time(s). Last edit at 03/20/2013 08:58AM by asdfg.
Re: Convert rewrite from apache to nginx
May 06, 2013 06:56AM
location / {
try_files $uri $uri/ =404;
}

location ~ ^/[^/]+/[^_]+_.*\.jpg$ {
return 301 /page.html;
# use "try_files" instead of "return 301" if page.html is a static page
# try_files /page.html $uri;
}

Andrejs
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 288
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready