I convert this .htaccess rewrite rule:
Into Nginx rewrite rule:
I have spent more than 4 hours to find a solution without luck.
Could someone that familiar with Nginx and Regular expression help me with this rewrite please....
- Code: Select all
RewriteRule ^news$ "$0/" [R=301,L,QSA]
RewriteRule ^news/$ news.php [L,QSA]
RewriteRule ^news/.*?([^\.\/]*)\.html$ news.php?pname=$1 [L,QSA]
RewriteRule ^news/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ news.php?d=$1$2$3 [L,QSA]
RewriteRule ^news/[^\.]*?([^/\.]*)/$ news.php?fname=$1 [L,QSA]
RewriteRule ^news/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]
Into Nginx rewrite rule:
- Code: Select all
rewrite ^/news$ /news/ permanent;
#301 redirect from "/news" to "/news/" --WORKS
rewrite ^/news/$ /news.php last;
#if uri "/news/" process by "/news.php" --WORKS
rewrite ^/news/.*?([^./]*).html$ /news.php?pname=$1 last;
#if example uri "/news/politic/fresh-political-news.html" should be process by "/news.php?pname=fresh-political-news" but it DOESN'T WORKS
rewrite "^/news/([1-2]d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$" /news.php?d=$1$2$3 last;
#I guess this is for archive by date. if example uri "/news/2015/05/30/" should be process by "/news.php?d=20150530" but it DOESN'T WORKS
rewrite ^/news/[^.]*?([^/.]*)/$ /news.php?fname=$1 last;
#if example uri "/news/politic/" process by "/news.php?fname=politic" --WORKS
rewrite ^/news/[^.]*?([^/.]*)$ /news/$1/ permanent;
#301 redirect from example uri "/news/politic" to "/news/politic/" --WORKS
NB: Note the comment
I have spent more than 4 hours to find a solution without luck.
Could someone that familiar with Nginx and Regular expression help me with this rewrite please....