Mohon bantuan, baru pindah dari Apache ke Nginx
February 19, 2015 09:35PM
Saya pengguna apache sebelumnya. baru coba pakai nginx dan memang sngat ringan dan cepat, sedikit makan resource. tapi ada 1 hal yang membuat saya pusing. REWRITE!. saya punya rule rewrite sederhana:

-jika ada file/folder ada, abaikan proses seperti biasa. (misal: website.com/index.php atau website.com/admin/)
-apapun variabel bawa ke website.com/index.php?mod=$1 (misal: website.com/kontak atau website.com/cari)

saya juga masih ragu aturan rewrite di tulis dalam locatin / {...} atau di luar.

htaccess saya di apache berjalan normal. tapi pas saya coba2 di nginx, malah ada index.php malah di download(parah nih), ada yang semua di oper ke index.php?mod=$ termasuk index.php dan /admin jadi: website.com/index.php?mod=index.php LOL atau website.com/index.php?mod=admin benar2 pusing saya. berikut file htaccess saya:

------------------------------------[begin]--------------------------
# Directory Index
DirectoryIndex index.php index.html

# 404 ERROR NOT FOUND
ErrorDocument 404 /404.php

# 301 REDIRECT WWW
RewriteCond %{HTTP_HOST} ^namawebsite.com$ [NC]
RewriteRule ^(.*)$ http://www.namawebsite.com/$1 [r=301,nc]

# IP Canonicalization
RewriteCond %{HTTP_HOST} ^111\.222\.333\.444
RewriteRule (.*) http://www.namawebsite.com/$1 [R=301,L]

# block exploits
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]

# libwww
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]

# NO rewrite for exact file/folder name
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# modul
RewriteRule ^([^/]+)/?$ index.php?mod=$1 [QSA,L]
RewriteRule ^([^/]+)/page/([0-9]+)/?$ index.php?mod=$1&page=$2 [QSA,L]

# XML file
RewriteRule (.*)\.xml(.*) $1.php$2 [nocase]
-------------------------------[end]--------------------------------

Mohon buat para master bantuannya seperti apa conf nya tuh
Re: Mohon bantuan, baru pindah dari Apache ke Nginx
November 24, 2015 10:55PM
ada tutornya gan,vps nya yang di pake apa?
kalo debian masuk sini aja gan
http://www.roryprayana.xyz/2015/11/debianid-config-nginx.html
kalo nggak install php dulu gan
http://www.roryprayana.xyz/2015/11/debianid-install-and-configure-php.html



Edited 1 time(s). Last edit at 11/24/2015 10:56PM by newbiedev.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 64
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready