Rewrite Rule convert
Igor Sysoev
igor at sysoev.ru
Fri Dec 3 10:24:00 MSK 2010
On Fri, Dec 03, 2010 at 01:54:18AM -0500, u-name wrote:
> I am a newer for the nginx
> I am tired to convert the rule form apache to nginx but it doesn't
> work.
> Anyone can help and point out my error?
> Thanks
>
> The Source Apache Rule:
> RewriteRule ^\/?index\.html$ /html/index.html [L]
> RewriteRule
> ^((ajax/|accounts/|software/download|shortcut|flashcookie)/?.*)$
> /index.php/$1 [L]
> RewriteRule ^\/?((cn|en|tw)?\/?([a-zA-Z][a-zA-Z0-9_\-]+)*\.html)$
> /html/$1 [L]
> RewriteRule ^\/?((cn|en|tw)?\/?news\/\d+)\.html$ /html/$1.html [L]
>
> My Convert Rules for Nginx:
> rewrite ^/?index\.html$ /html/index.html last;\
> rewrite ^((ajax/|accounts/|software/download|shortcut|flashcookie)/?.*)$
> /index.php/$1 last;
> rewrite ^/\/?((cn|en|tw)?\/?([a-zA-Z][a-zA-Z0-9_\-]+)*\.html)$ /html/$1
> last;
> rewrite ^\/?((cn|en|tw)?\/?news\/\d+)\.html$ /html/$1.html last;
>
> Now I link to my ajax/|accounts/|software/download|shortcut|flashcookie
> page, it show error 404
Sorry, it's not easy to understand these regexs.
What does "^\/?((cn|en|tw)?\/?news\/\d+)\.html$" mean ?
Should it match "/ennews/5.html", for example ?
You should location instead rewrites, for example:
locaiton = /index.html {
root /path/to/html;
}
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list