CakePHP + Nginx dan .htaccess
Buat yang pake CakePHP tapi webserver-nya Nginx (with PHP-FPM). Berikut contoh konfigurasi Nginx yang saya pakai.
(Catatan : PHP-FPM nya jalan di Unix socket ya.., bukan di Port 9000. Kalau PHP-FPM anda jalan di Port 9000, sesuaikan saja).
server { listen 80; server_name www.websitemu.com; root /var/www/app/webroot;
client\_max\_body\_size 10m;
access\_log /var/log/nginx/access.log;
location / {
root /var/www/app/webroot;
index index.php index.html index.htm;
#baris dibawah ini sebagai pengganti .htaccess untuk CakePHP
if (!-e $request\_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
}
# baris - baris berikut ini untuk Cache, harusnya ada yang lebih simpel
# (bisa dijadikan satu paramater), tapi yang saya coba
# gagal melulu, jadi demi mengejar waktu live, ini dulu yang dipakai
location ~\* \\favicon.ico$ {
access\_log off;
expires 30d;
add\_header Cache-Control public;
}
location ~ \\.css$ {
access\_log off;
expires 30d;
add\_header Cache-Control public;
}
location ~ \\.js$ {
access\_log off;
expires 30d;
add\_header Cache-Control public;
}
# baris berikut untuk setting PHP-FPM nya.
location ~ \\.php$ {
#fastcgi\_pass 127.0.0.1:9000;
fastcgi\_pass unix:/var/run/php-fpm.sock;
fastcgi\_index index.php;
fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;
include fastcgi\_params;
}
location ~ /\\.ht {
deny all;
}
}
salam kenal bRo, saya lagi testing phpmotion di nginx, u/ setup nya berhasil tinggal di htaccess nya nih bersalamah hehehe. untuk location ~ /\.ht fungsinya apa yah.?
saya bingung di konfigurasi
order allow,deny
allow from all
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule \.(css|jpe?g|gif|png|flv|swf)$ – last;
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/members/(.?)$ /people [R=301]
RewriteCond %{QUERY_STRING} (\<||>) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteCond %{QUERY_STRING} SELECT(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} UNION(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteRule ^(.*)$ index.php [F,L]
Options -Indexes
SecFilterEngine Off
SecFilterScanPOST Off
ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
Cara nerjemahin ke nginx nya gmn.?
mohon pencerahan nya..