简体   繁体   中英

How do i convert this Mod_rewrite rule to nginx

This is the Htacces rule:

RewriteEngine on
RewriteRule ^([A-Za-z0-9-]+)/?$ ir.php?id=$1

how should I pass it to a Nginx compliant rewrite rule... i read the doc and did this:

rewrite ^([A-Za-z0-9-]+)/?$ ir.php?id=$1 last;

But didnt work. and another question: Is there any equivalent of .htaccess to Nginx (per directory rules) Thanks

Finally, could solve it... rewrite ^([A-Za-z0-9-]+)/?$ ir.php?id=$1 last; To rewrite ^/([A-Za-z0-9-]+)/?$ /ir.php?id=$1 last;

As an answer to your second question: no, there is no equivalent for Apache's .htaccess files for per directory configuration. You can have per directory configuration files included via the master config, but Nginx would need to be reloaded every time a config include file changed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM