Question

Someone help me with mod_rewrite Nginx

This is .htaccess

Options -Indexes RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/index. RewriteCond %{REQUEST_URI} !^/$

RewriteRule ^([^/])$ /?page=$1 [L,QSA] RewriteRule ^([^-])/([^-]*)/$ /?page=$1&act=$2 [QSA,L]

RewriteRule ^upload/([^/])$ /?page=upload&act=$1 [L] RewriteRule ^torrents/([0-9]+)$ /?page=torrents&next=$1 [L,QSA] RewriteRule ^torrents/cat/([^/])$ /?page=torrents&catid=$1 [L,QSA] RewriteRule ^torrents/cat/([^/])/([^/])$ /?page=torrents&catid=$1&next=$2 [L,QSA]
RewriteRule ^torrents/search/([^/])$ /?page=torrents&search=$1 [L,QSA] RewriteRule ^torrents/search/([^/])/([^/])$ /?page=torrents&search=$1&next=$2 [L,QSA] RewriteRule ^torrents/([^/])/([^/])$ /?page=torrents&sortedBy=$1&axis=$2 [L,QSA] RewriteRule ^torrents/([^/])/([^/])/([^/])$ /?page=torrents&next=$1&sortedBy=$2&axis=$3 [L,QSA]
RewriteRule ^torrents/cat/([^/])/([^/])/([^/])$ /?page=torrents&catid=$1&sortedBy=$2&axis=$3 [L,QSA] RewriteRule ^torrents/cat/([^/])/([^/])/([^/])/([^/])$ /?page=torrents&catid=$1&next=$2&sortedBy=$3&axis=$4 [L,QSA] RewriteRule ^torrent-detail/([^/])$ /?page=torrent-detail&id=$1 [L,QSA] RewriteRule ^torrent-detail/([^/])/([^/])$ /?page=torrent-detail&id=$1&urlTitle=$2 [L,QSA] RewriteRule ^torrent-edit/([^/])/([^/])$ /?page=torrent-edit&id=$1&urlTitle=$2 [L] RewriteRule ^torrent-delete/([^/])/([^/])$ /?page=torrent-delete&id=$1&hash=$2 [L] RewriteRule ^download/([^/])$ /?page=download&hash=$1 [L] RewriteRule ^rss/([^/])$ /?page=rss&cat=$1 [L] RewriteRule ^account/([0-9]+)$ /?page=account&next=$1 [QSA,L] RewriteRule ^admincp/users/([0-9]+)$ /?page=admincp&act=users&next=$1 [QSA,L]

I use Nginx unbuntu 14-04

How to change in nginx conf

and this is in subfolder torrent

is like www.domain.com/torrent

Pls any help i will be greatful. Tnx .


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

tnx ryanpq , but i use that convertor and is old and is not good .

i use this conf

autoindex off;
location /torrent/ {
if (!-f $request_filename){
   set $rule_0 1$rule_0;
}
if (!-d $request_filename){
   set $rule_0 2$rule_0;
}
if ($uri !~ "^/index\."){
   set $rule_0 3$rule_0;
}
if ($uri !~ "^/$"){
   set $rule_0 4$rule_0;
}
if ($rule_0 = "4321"){
   rewrite ^/([^/]*)$ /?page=$1 last;
}
rewrite ^/([^-]*)/([^-]*)/$ /?page=$1&act=$2 last;
rewrite ^/upload/([^/]*)$ /?page=upload&act=$1 last;
rewrite ^/torrents/([0-9]+)$ /?page=torrents&next=$1 last;
rewrite ^/torrents/cat/([^/]*)$ /?page=torrents&catid=$1 last;
rewrite ^/torrents/cat/([^/]*)/([^/]*)$ /?page=torrents&catid=$1&next=$2 last;
rewrite ^/torrents/search/([^/]*)$ /?page=torrents&search=$1 last;
rewrite ^/torrents/([^/]*)/([^/]*)$ /?page=torrents&sortedBy=$1&axis=$2 last;
rewrite ^/torrents/([^/]*)/([^/]*)/([^/]*)$ /?page=torrents&next=$1&sortedBy=$2&axis=$3 last;
rewrite ^/torrents/cat/([^/]*)/([^/]*)/([^/]*)$ /?page=torrents&catid=$1&sortedBy=$2&axis=$3 last;
rewrite ^/torrents/cat/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /?page=torrents&catid=$1&next=$2&sortedBy=$3&axis=$4 last;
rewrite ^/torrent-detail/([^/]*)$ /?page=torrent-detail&id=$1 last;
rewrite ^/torrent-detail/([^/]*)/([^/]*)$ /?page=torrent-detail&id=$1&urlTitle=$2 last;
rewrite ^/torrent-edit/([^/]*)/([^/]*)$ /?page=torrent-edit&id=$1&urlTitle=$2 last;
rewrite ^/torrent-delete/([^/]*)/([^/]*)$ /?page=torrent-delete&id=$1&hash=$2 last;
rewrite ^/download/([^/]*)$ /?page=download&hash=$1 last;
rewrite ^/rss/([^/]*)$ /?page=rss&cat=$1 last;
rewrite ^/account/([0-9]+)$ /?page=account&next=$1 last;
rewrite ^/admincp/users/([0-9]+)$ /?page=admincp&act=users&next=$1 last;
}

and stil not work :( pls someone help me ? :)

This handy site does Apache .htaccess to nginx configuration translation and should help. Near the top of what it generates should be a Location / line. If this file was located in /torrents then you will need to update it so the rules are applied only to that directory.