URL Rewriting under Nginx


I am trying to put an old PHP app, I used a few years ago, but it was running under Apache… That’s why I was trying to fit the .htaccess rewriting rules in the conf file of nginx, after changing it to make work those rules :

RewriteBase /en/
RewriteRule ^blog.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /en/blog.php [L]

I tried following, but it doesn’t work…

if (!-f $request_filename){
set $rule_1 1$rule_1;
if (!-d $request_filename){
set $rule_1 2$rule_1;
if ($rule_1 = “21”){
rewrite /. /en/blog.php last;

Could someone please help me? Thank you!

Apparently, these rewrite conditions are :

location /en/ {
  if (!-e $request_filename){
    rewrite ^/en/(.*)$ /en/blog.php break;

It’s the base :slight_smile: so it opens {}

Rule which will be in the condition

The condition before.

There is a converter (I used) which translates HtAccess Rules to Nginx rewrite rules : https://www.winginx.com/en/htaccess

I don’t know if it’s good or not.

I know this website ; it is not working at all ; a lot of conditions are missing…