I have a website running on MechBunny tube script, and I only host this website on 1 dedicated server, running on Nginx. The script creator told me, I'll have to convert .htaccess file to nginx, otherwise the website will not work properly.
I also have in /etc/nginx/ the following:
/conf.d
/sites-available/MySite.com.conf
/sites-enabled/MySite.com.conf
My questions are:
is my nginx file correct?
where should I add this ng file?
Converted .htaccess file to Nginx:
# nginx configuration by winginx.com
autoindex off;
index index.php;
charset utf-8;
error_page 404 /404.php;
error_page 403 /403.php;
autoindex off;
location / {
rewrite \.(gif|jpe?g|png) /image404.php break;
rewrite ^(.*)$ https://$http_host$request_uri redirect;
}
location /ajax {
rewrite ^/ajax/([a-z-]+)$ /core/ajax/$1.php break;
}
location = /filters {
rewrite ^(.*)$ /index.php?controller=filters break;
}
location /page {
rewrite ^/page([0-9]+).html$ /index.php?controller=index&page=$1 break;
}
location /galleries {
rewrite ^/galleries/(.*)-([0-9]+).html$ /index.php?controller=gallery&id=$2;
}
location /video {
rewrite ^/video/(.*)-([0-9]+).html$ /index.php?controller=video&id=$2;
}
location /webcam {
rewrite ^/webcam-video/(.*)-(.*).html$ /index.php?controller=video&id=$2&awe=1;
}
location = /signup {
rewrite ^(.*)$ /index.php?controller=signup;
}
location = /tokens {
rewrite ^(.*)$ /index.php?controller=tokens;
}
location = /validate {
rewrite ^(.*)$ /index.php?controller=validate;
}
location = /upload_choose {
rewrite ^(.*)$ /index.php?controller=upload_choose;
}
location = /upload {
rewrite ^(.*)$ /index.php?controller=upload;
}
location = /upload_photo {
rewrite ^(.*)$ /index.php?controller=upload&option=photo;
}
location = /login {
rewrite ^(.*)$ /index.php?controller=login;
}
location = /logout {
rewrite ^(.*)$ /index.php?controller=logout;
}
location = /contact {
rewrite ^(.*)$ /index.php?controller=contact;
}
location /forgot {
rewrite ^/forgot-pass$ /index.php?controller=forgot_pass;
}
location /my {
rewrite ^/my-profile$ /index.php?controller=my_profile break;
rewrite ^/my-friends$ /index.php?controller=my_friends;
rewrite ^/my-friends/$ /index.php?controller=friends;
rewrite ^/my-friends/page([0-9]+).html$ /index.php?controller=friends&page=$1;
}
location /edit {
rewrite ^/edit-profile$ /index.php?controller=edit_profile break;
rewrite ^/edit-content/(.*)$ /index.php?controller=editContent&id=$1;
}
location /static {
rewrite ^/static/(.*)$ /index.php?controller=displayStatic&id=$1;
}
location /load {
rewrite ^/load/(.*)$ /index.php?controller=loadLayout&id=$1;
}
location /filter {
rewrite ^/filter/(.*)$ /index.php?controller=setFilter&id=$1;
rewrite ^/filter-content/(.*)$ /index.php?controller=setFilterContent&id=$1;
}
location = /unsetFilters {
rewrite ^(.*)$ /index.php?controller=unsetMembersFilter break;
}
location /change {
rewrite ^/change-colors$ /index.php?controller=changeColors;
}
location /embed {
rewrite ^/embed/([0-9]+)$ /index.php?controller=embed&id=$1;
}
location = /404.php {
rewrite ^(.*)$ /index.php?controller=404;
}
location = /403.php {
rewrite ^(.*)$ /index.php?controller=403;
}
location /crss {
rewrite ^/crss/([0-9]+)$ /index.php?controller=crss&id=$1;
}
location = /rss {
rewrite ^(.*)$ /index.php?controller=rss;
}
location /a {
rewrite ^/a/(.*)$ /index.php?controller=link&slug=$1;
}
location /webvtt {
rewrite ^/webvtt/([0-9]+).vtt$ /index.php?controller=webvtt&id=$1;
}
location /purchase {
rewrite ^/purchase/([0-9]+)$ /index.php?controller=rentVideo&id=$1;
}
location /buy {
rewrite ^/buy-tokens$ /index.php?controller=buyTokens;
}
location /vr {
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ /index.php?controller=index&mode=$1;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=$3;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
}
location /my-uploads {
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ /index.php?controller=index&mode=$1;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=$3;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
}
location /favorites {
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ /index.php?controller=index&mode=$1;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=$3;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
}
location /most-recent {
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ /index.php?controller=index&mode=$1;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=$3;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
}
location /most-discussed {
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ /index.php?controller=index&mode=$1;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=$3;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
}
location /most-viewed {
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ /index.php?controller=index&mode=$1;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=$3;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
}
location /longest {
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ /index.php?controller=index&mode=$1;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=$3;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
}
location /top-rated {
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ /index.php?controller=index&mode=$1;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=$3;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
}
location /photos {
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ /index.php?controller=index&mode=$1;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=$3;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/photos/(most-recent|most-discussed|most-viewed|top-rated)/$ /index.php?controller=index&mode=photos&sortby=$1;
rewrite ^/photos/(most-recent|most-discussed|most-viewed|top-rated)/page([0-9]+).html$ /index.php?controller=index&mode=photos&sortby=$1;
}
location /random {
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ /index.php?controller=index&mode=$1;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=$3;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
}
location /my-friends {
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ /index.php?controller=index&mode=$1;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=$3;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
}
location /videos {
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ /index.php?controller=index&mode=$1;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=$3;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
}
location /my-rentals {
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ /index.php?controller=index&mode=$1;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=$3;
rewrite ^/(vr|my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
}
location /uploads {
rewrite ^/uploads-by-user/([0-9]+)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=uploads-by-user&user=$1&dateRange=$2&page=$3;
rewrite ^/uploads-by-user/([0-9]+)/(day|week|month)/$ /index.php?controller=index&mode=uploads-by-user&user=$1&dateRange=$2;
rewrite ^/uploads-by-user/([0-9]+)/page([0-9]+).html$ /index.php?controller=index&mode=uploads-by-user&user=$1&page=$2;
rewrite ^/uploads-by-user/([0-9]+)/$ /index.php?controller=index&mode=uploads-by-user&user=$1;
}
location /search {
rewrite ^/search/(videos|members|photos)/(.*)/(newest|rating|views|longest)/$ /index.php?controller=index&mode=search&type=$1&q=$2&page=1&sortby=$3;
rewrite ^/search/(videos|members|photos)/(.*)/(newest|rating|views|longest)/page([0-9]+).html$ /index.php?controller=index&mode=search&type=$1&q=$2&page=$4&sortby=$3;
rewrite ^/search/(videos|members|photos)/(.*)/$ /index.php?controller=index&mode=search&type=$1&q=$2&page=1;
rewrite ^/search/(videos|members|photos)/(.*)/page([0-9]+).html$ /index.php?controller=index&mode=search&type=$1&q=$2&page=$3;
rewrite ^/search/(.*)/(newest|rating|views|longest)/$ /index.php?controller=index&mode=search&q=$1&page=1&sortby=$2;
rewrite ^/search/(.*)/(newest|rating|views|longest)/page([0-9]+).html$ /index.php?controller=index&mode=search&q=$1&page=$3&sortby=$2;
rewrite ^/search/(.*)/$ /index.php?controller=index&mode=search&q=$1&page=1;
rewrite ^/search/(.*)/page([0-9]+).html$ /index.php?controller=index&mode=search&q=$1&page=$2;
}
location = /channels {
rewrite ^(.*)$ /index.php?controller=channels;
}
location /channels {
rewrite ^/channels/([0-9]+)/(.*)/(newest|rating|views|longest)/$ /index.php?controller=index&mode=channel&channel=$1&sortby=$3;
rewrite ^/channels/([0-9]+)/(.*)/(newest|rating|views|longest)/page([0-9]+).html$ /index.php?mode=channel&channel=$1&sortby=$3&page=$4;
rewrite ^/channels/([0-9]+)/(.*)/$ /index.php?controller=index&mode=channel&channel=$1;
rewrite ^/channels/([0-9]+)/(.*)/page([0-9]+).html$ /index.php?controller=index&mode=channel&channel=$1&page=$3;
}
location = /paysites {
rewrite ^(.*)$ /index.php?controller=paysites;
}
location /paysites {
rewrite ^/paysites/([0-9]+)/(.*)/(newest|rating|views|longest)/$ /index.php?controller=index&mode=paysites&paysite=$1&sortby=$3;
rewrite ^/paysites/([0-9]+)/(.*)/(newest|rating|views|longest)/page([0-9]+).html$ /index.php?mode=paysites&paysite=$1&sortby=$3&page=$4;
rewrite ^/paysites/([0-9]+)/(.*)/$ /index.php?controller=index&mode=paysites&paysite=$1;
rewrite ^/paysites/([0-9]+)/(.*)/page([0-9]+).html$ /index.php?controller=index&mode=paysites&paysite=$1&page=$3;
}
location /pornstars {
rewrite ^(.*)$ /index.php?controller=pornstars;
rewrite ^/(pornstars|models)/(alphabetical|rating)/$ /index.php?controller=pornstars&sortby=$2;
rewrite ^/(pornstars|models)/page([0-9]+).html$ /index.php?controller=pornstars&page=$2;
rewrite ^/(pornstars|models)/(alphabetical|rating)/page([0-9]+).html$ /index.php?controller=pornstars&sortby=$2&page=$3;
rewrite ^/(pornstars|models)/(.*)/page([0-9]+).html$ /index.php?controller=pornstars&letter=$2&page=$3;
rewrite ^/(pornstars|models)/(.*)/(alphabetical|rating)/$ /index.php?controller=pornstars&letter=$2&sortby=$3&page=1;
rewrite ^/(pornstars|models)/(.*)/(alphabetical|rating)/page([0-9]+).html$ /index.php?controller=pornstars&letter=$2&sortby=$3&page=$4;
rewrite ^/(pornstars|models)/(.*)-([0-9]+).html$ /index.php?controller=pornstar_bio&id=$3 break;
rewrite ^/(pornstars|models)/(.*)/$ /index.php?controller=pornstars&letter=$2&page=1;
}
location /models {
rewrite ^(.*)$ /index.php?controller=pornstars;
rewrite ^/(pornstars|models)/(alphabetical|rating)/$ /index.php?controller=pornstars&sortby=$2;
rewrite ^/(pornstars|models)/page([0-9]+).html$ /index.php?controller=pornstars&page=$2;
rewrite ^/(pornstars|models)/(alphabetical|rating)/page([0-9]+).html$ /index.php?controller=pornstars&sortby=$2&page=$3;
rewrite ^/(pornstars|models)/(.*)/page([0-9]+).html$ /index.php?controller=pornstars&letter=$2&page=$3;
rewrite ^/(pornstars|models)/(.*)/(alphabetical|rating)/$ /index.php?controller=pornstars&letter=$2&sortby=$3&page=1;
rewrite ^/(pornstars|models)/(.*)/(alphabetical|rating)/page([0-9]+).html$ /index.php?controller=pornstars&letter=$2&sortby=$3&page=$4;
rewrite ^/(pornstars|models)/(.*)-([0-9]+).html$ /index.php?controller=pornstar_bio&id=$3 break;
rewrite ^/(pornstars|models)/(.*)/$ /index.php?controller=pornstars&letter=$2&page=1;
}
location = /mailbox {
rewrite ^(.*)$ /mailbox.php break;
}
location /mailbox {
rewrite ^/mailbox/([0-9]+)$ /mailbox.php?mode=inbox&page=$1 break;
rewrite ^/mailbox/inbox/([0-9]+)$ /mailbox.php?mode=inbox&page=$1 break;
rewrite ^/mailbox/outbox/([0-9]+)$ /mailbox.php?mode=outbox&page=$1 break;
rewrite ^/mailbox/read/([0-9]+)$ /mailbox.php?mode=read&mid=$1 break;
rewrite ^/mailbox/read/([0-9]+)/delete/$ /mailbox.php?mode=read&mid=$1&delete=true;
rewrite ^/mailbox/read/([0-9]+)/spam/$ /mailbox.php?mode=read&mid=$1&spam=true;
rewrite ^/mailbox/compose/([0-9]+)/reply/$ /mailbox.php?mode=compose&mid=$1&reply=true;
}
location = /mailbox/inbox {
rewrite ^(.*)$ /mailbox.php?mode=inbox break;
}
location = /mailbox/outbox {
rewrite ^(.*)$ /mailbox.php?mode=outbox break;
}
location = /mailbox/compose {
rewrite ^(.*)$ /mailbox.php?mode=compose;
}
location /user {
rewrite ^/user/(.*)-([0-9]+)/$ /index.php?controller=user_profile&id=$2;
}
location = /members {
rewrite ^(.*)$ /index.php?controller=members;
}
location /members {
rewrite ^/members/page([0-9]+).html$ /index.php?controller=members&page=$1;
}
location = /tags {
rewrite ^(.*)$ /index.php?controller=tags&page=1;
}
location /tags {
rewrite ^/tags/(.*)$ /index.php?controller=tags&letter=$1;
}
location /online {
rewrite ^/online-cams/$ /index.php?controller=aweonlinecams&page=1;
rewrite ^/online-cams/page([0-9]+).html$ /index.php?controller=aweonlinecams&page=$1;
}
location /live {
rewrite ^/live-webcams/loadMaster/(.*)$ /includes/ajax.aweblacklabel_loadmaster.php?id=$1;
rewrite ^/live-webcams/loadModel/(.*)$ /includes/ajax.aweblacklabel_loadmodel.php?id=$1;
rewrite ^/live-webcams/loadVideos/(.*)$ /includes/ajax.aweblacklabel_loadvideos.php?id=$1;
rewrite ^/live-webcams/loadGalleries/(.*)$ /includes/ajax.aweblacklabel_loadgalleries.php?id=$1;
rewrite ^/live-webcams/loadRecommended/(.*)$ /includes/ajax.aweblacklabel_loadrecommended.php?id=$1;
rewrite ^/live-webcams/loadMore/(.*)$ /includes/ajax.aweblacklabel_loadmore.php?listPageId=$1;
rewrite ^/live-webcams/paymentCallback$ /index.php?controller=aweblacklabel&paymentCallback=1;
rewrite ^/live-webcams/$ /index.php?controller=aweblacklabel&page=1;
rewrite ^/live-webcams/page([0-9]+).html$ /index.php?controller=aweblacklabel&page=$1;
}
Thank you.
you don't need to convert htaccess to nginx also there a lot of think's you can do it by one Location Block and you forget the server and server_name and fastcgi you see Creating NGINX Rewrite Rules
Related
Can I setup Varnish for one Subdomain and block it for all other Domains on my server?
Will this code work?
backend magento244.example.com {
.host = "magento244.example.com";
.port = "8080";
.first_byte_timeout = 600s;
.probe = {
.url = "/health_check.php";
.timeout = 2s;
.interval = 5s;
.window = 10;
.threshold = 5;
}
}
if (req.http.host == 'www.example.com') {
return (pass);
}
The code you provided will bypass the cache for www.example.com requests.
Assuming you only want traffic to be handled for www.example.com and you want to block all other traffic, I'd use the following VCL code:
sub vcl_recv {
// Block requests for other hosts
if(req.http.Host != "www.example.com") {
return(synth(403));
}
// The rest of your VCL code can go here
}
This code will return a 403 Forbidden status for all requests that are not for the www.example.com host.
If you have a different interpretation of blocking requests, please update your question and provide more context.
Here is my .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mywebsite\.com [NC]
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
And here is my index.php file:
<?php
$GLOBALS["DEBUG"] = true;
$GLOBALS["DEBUG_MODE"] = "file";
// $GLOBALS["DEBUG_MODE"] = "stdout";
// $GLOBALS["DEBUG_MODE"] = "global";
$GLOBALS["DEBUG_REGEX"] = "^[^b]";
$GLOBALS["ERROR_LOG"] = true;
// $GLOBALS["DEBUG_SQL"] = true;
// $GLOBALS["PROFILER_SQL"] = true;
// $GLOBALS["DEBUG_CLASS_WALK"] = true;
// $GLOBALS["DEBUG_CLASS_FOUND"] = true;
// $GLOBALS["DEBUG_CLASS_MATCH"] = "c_";
define("DIR_WEBROOT", realpath(dirname(__FILE__)));
include DIR_WEBROOT . "/xfw/app/startup.php";
d();
// pr(db0()->oQueryFetchArray("SELECT * FROM core_contact"));
pr(r::parseUrl());
if ($a = x_Route::path("^/JSON/(JSON|RAW|DIRECT)/([^/]*)/([^/]*)")) {
$class = $a[2];
$method = $a[3];
$a_params = json_decode(trim(file_get_contents("php://input")), true);
// $a_params = array_map('sql_escape_string', $a_params);
try {
$data = [
"message" => "ok",
"data" => call_user_func_array("$class::$method", [$a_params]),
];
} catch (Exception $e) {
$data = [
"message" => "Erreur",
"data" => $e->getMessage() . "\n\n" . getExceptionTraceAsString($e),
];
h("err");
pr(getExceptionTraceAsString($e));
h("$class::$method");
pr($a_params);
}
if ($a[1] == "JSON") {
echo json_encode($data);
} elseif ($a[1] == "DIRECT") {
echo json_encode($data["data"]);
} else {
echo $data;
}
exit;
}
if ($a = r::path("^/$")) {
header("Location: /fr/ ");
exit;
}
if (!r::path("/$")) {
header("Location: ".ROUTE_PATH."/");
exit;
}
if ($a = r::path("^/fr/$")) {
echo View::renderTemplatePublic("public/fr/home.html");
exit;
}
if ($a = r::path("^/fr/contact/$")) {
echo View::renderTemplatePublic("public/fr/contact.html", [
"message" => c_Page::message()
]);
exit;
}
if ($a = r::path("^/fr/(.*)/")) {
echo View::renderTemplatePublic("public/fr/$a[1].html");
exit;
}
I want a rule that would add a trailing slash to all URLs except for URLs with an extension (.pdf, .html, ...). Could anyone help me achieve this so that when I have a URL like mywebsite.com/example.pdf it does not redirect me to mywebsite.com/example.pdf/ with a trailing slash at the end?
Looks like
if (!r::path("/$")) {
header("Location: ".ROUTE_PATH."/");
exit;
}
is the part that needs to be modified here. This appears to be using regular expressions; /$ only checks if the value ends with a slash, and the condition is negated, to redirect when it doesn’t.
Instead of trying to come up with a more complex regular expression, I’d probably use pathinfo here. Try and replace that section with
if (!r::path("/$") && pathinfo(ROUTE_PATH, PATHINFO_EXTENSION) === '') {
header("Location: ".ROUTE_PATH."/");
exit;
}
The PATHINFO_EXTENSION flag makes pathinfo return the extension only, and if the path didn’t actually have any, it will just return an empty string.
I want to rewrite a url which is simple by using the UseRewriter Middleware.
var rewrite = new RewriteOptions()
.AddRedirect("Page1From", "Page1To") // Redirect
.AddRewrite("Page2From", "Page2To", true); // Rewrite
app.UseRewriter(rewrite);
This will have as a result, the url "/Page1From" will be redirected to "Page1To" and the url "Page2From" will display the contents of the "/Page2To" without redirect.
I want to implement the AddRewrite method by using data from database but I only found how to redirect using a custom Rule.
var rewrite = new RewriteOptions()
.AddRedirect("Page1From", "Page1To") // Redirect
.AddRewrite("Page2From", "Page2To", true); // Rewrite
.Add(new MoviesRedirectRule( // Custom Rule
matchPaths: new[] { "/Page3From1", "/Page3From2", "/Page3From3" },
newPath: "/Page3To"));
app.UseRewriter(rewrite);
and the rule is the following:
public class MoviesRedirectRule : IRule
{
private readonly string[] matchPaths;
private readonly PathString newPath;
public MoviesRedirectRule(string[] matchPaths, string newPath)
{
this.matchPaths = matchPaths;
this.newPath = new PathString(newPath);
}
public void ApplyRule(RewriteContext context)
{
var request = context.HttpContext.Request;
// if already redirected, skip
if (request.Path.StartsWithSegments(new PathString(this.newPath)))
{
return;
}
if (this.matchPaths.Contains(request.Path.Value))
{
var newLocation = $"{this.newPath}{request.QueryString}";
var response = context.HttpContext.Response;
response.StatusCode = StatusCodes.Status302Found;
context.Result = RuleResult.EndResponse;
response.Headers[HeaderNames.Location] = newLocation;
}
}
}
This will redirect the following urls:
/Page3From1
/Page3From2
/Page3From3
to /Page3To
I want to create something similar which will not redirect but I want to Rewrite the url so that the url will remain the same but it will display the contents of a specified URL.
Can someone tell me what changes I have to do to the response object in order to make it work?
RewriteRule that is added when you call AddRewrite() just replaces URI parts in request (link to source code):
request.Scheme = scheme;
request.Host = host;
request.Path = pathString;
request.QueryString = query.Add(request.QueryString);
In your case, since you are replacing only Path part, ApplyRule method would be as simple as:
public void ApplyRule(RewriteContext context)
{
var request = context.HttpContext.Request;
if (matchPaths.Contains(request.Path.Value))
{
request.Path = newPath;
context.Result = RuleResult.SkipRemainingRules;
}
}
first of all, sorry for my poor english it's not my natural language.
I try to configure varnish with cookies for managment users to backend, and i have some issues to loggin and other checks.
My config for recv, fetch and hash:
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
remove req.http.X-Forwarded-For;
set req.http.X-Forwarded-For = client.ip;
if (req.request == "POST"){
return (pass);
}
# Grace mode
if (! req.backend.healthy) {
set req.grace = 30m;
} else {
set req.grace = 15s;
}
if(req.url ~ "^localhost$"){
set req.http.host = "www.micasa.com";
}
# Acces to system URL's is protected
if ((req.url ~ "^/server_status") || (req.url ~ "^/discover/varnish_server")) {
error 403 "Go away, please";
}
# Delete all cookies except from user
if ( !(req.url ~ "^/logout") &&
!(req.url ~ "^/profile") &&
!(req.url ~ "^/playlists") &&
!(req.url ~ "^/users") &&
!(req.url ~ "^/signup") &&
!(req.url ~ "^/comments") &&
!(req.url ~ "^/login") &&
!(req.url ~ "^/remind"))
{
unset req.http.cookie;
}
sub vcl_fetch {
# Grace mode
# https://www.varnish-cache.org/docs/trunk/tutorial/handling_misbehaving_servers.html#grace-mode
set beresp.grace = 30m;
# Saint mode
# https://www.varnish-cache.org/docs/trunk/tutorial/handling_misbehaving_servers.html#saint-mode
if (beresp.status == 500) {
set beresp.saintmode = 10s;
return (restart);
}
if ( !(req.url ~ "^/login") && (req.request == "GET")){
unset beresp.http.set-cookie; # To avoid caching of cookies
}
# Process ESIs if X-RUN-ESI is set. This will be stripped before being sent down to client.
if ( beresp.http.X-RUN-ESI ) {
set beresp.do_esi = true;
remove beresp.http.X-RUN-ESI;
}
# cache 404s and 301s for 5 minute
if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) {
set beresp.ttl = 15m;
return (deliver);
}
# cache images and static assets during 15m
if ( req.url ~ "\.(png|gif|jpg|css|js|ico)" ) {
set beresp.ttl = 15m;
return (deliver);
}
# If X-VARNISH-TTL is set, use this header's value as the TTL for the varnish cache.
# Expires, cache-control, etc. will be passed directly through to the client
# Cribbed from http://www.lovelysystems.com/configuring-varnish-to-use-custom-http-headers/
if (beresp.http.X-VARNISH-TTL) {
C{
char *ttl;
/* first char in third param is length of header plus colon in octal */
ttl = VRT_GetHdr(sp, HDR_BERESP, "\016X-VARNISH-TTL:");
VRT_l_beresp_ttl(sp, atoi(ttl));
}C
remove beresp.http.X-VARNISH-TTL;
return (deliver);
}
sub vcl_deliver {
unset resp.http.x-url; # Optional
if ( req.url ~ "\.(png|gif|jpg|css|js|ico|woff)" ) {
set resp.http.expires = "3600";
}
#mikel
#remove resp.http.X-Powered-By;
remove resp.http.Server;
#remove resp.http.X-Varnish;
#remove resp.http.Via;
#remove resp.http.Age;
}
sub vcl_hash {
if (req.http.Cookie ~ "_micasa_session") {
hash_data(req.url);
hash_data(req.http.Cookie);
return (hash);
}
}
When i try to loggin with user it's ok, but if i refresh the same page after that, i lose cookie and immediatly logout, maybe the problem is in sub vcl_recv?
Thank's for advance for you help.
You unset all cookies except for on the defined pages. Your site login is almost certainly held in a cookie (session cookie?). The easy way out is to disable cache for logged in users by checking if some cookie identifying a logged in user is set. The good way is to use ESI so that sections that are the same for all users gets cached.
Is there a way to provide a static list of URLs to cache? I know that I can put a bunch of 'if' statements in the VCL but I am wondering if there is a more elegant way.
Put them to regular expression
if (req.url ~ "^/(some/url/1|some/url/2|....|some/urlN)") {
unset req.http.Cookie;
return (lookup);
}
else {
return (pass);
}
or just list with ||
if (req.url ~ "^/some/url/1"
|| req.url ~ "^/some/url/2
...
|| req.url ~ "^/some/urlN"
) {
unset req.http.Cookie;
return (lookup);
}