Htaccess to nginx


#1

I have few rules in htaccess file, these help me to fix old url 404 error

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$ https://www.example.com/$3
RedirectMatch 301 ^/blog/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$ https://www.example.com/$3

Now I’m moving to lemp server and I need to convert these rules for nginx server block but after searching a lot, I didn’t find the solution. Please help me to convert and fix 404 error.


#2

Hi…

To convert .htaccess rule to Nginx config

Try these sites

Still unable to do?
A) Try Redirection plugin with Regular Expression.
B) Guess, they offer export Nginx compiled rule also. Please check.

Thanks


#3

these sites didn’t work for these rules, I tried, but it has been solved now:

> rewrite "^/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$" https://www.example.com/$3 permanent;
> rewrite "^/blog\/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$" https://www.example.com/$3 permanent;

#4

You can close the thread.
Thanks for help.


#5

You’re welcome!

Keeping this topic open may help other to get/share answer on the this question. :thinking:


#6

Okay, no problem. :grinning: