diff --git a/TROUBLESHOOTING_REDIRECT.md b/TROUBLESHOOTING_REDIRECT.md new file mode 100644 index 0000000..df6d0c3 --- /dev/null +++ b/TROUBLESHOOTING_REDIRECT.md @@ -0,0 +1,118 @@ +# Troubleshooting ERR_TOO_MANY_REDIRECTS + +## Penyebab Umum + +1. **Konfigurasi Nginx/Apache** yang redirect `/` ke `/index.php` +2. **.htaccess** di root yang melakukan redirect +3. **JavaScript redirect** yang menyebabkan loop + +## Solusi + +### 1. Cek Konfigurasi Nginx + +Pastikan di server production, konfigurasi nginx TIDAK melakukan redirect loop: + +```nginx +server { + root /www/wwwroot/retribusi.btekno.cloud/retribusi/public; + index index.php index.html; + + location / { + # JANGAN gunakan redirect ke index.php jika sudah di root + try_files $uri $uri/ =404; + } + + location ~ \.php$ { + fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} +``` + +**PENTING**: +- Document root HARUS di `/retribusi/public` (bukan `/retribusi`) +- JANGAN gunakan `try_files $uri $uri/ /index.php?$query_string;` di root location + +### 2. Cek .htaccess + +Pastikan `.htaccess` di folder `public/` TIDAK melakukan redirect: +- File `.htaccess` di `public/` sudah benar (tidak ada redirect) +- Jika ada `.htaccess` di root, pastikan tidak ada redirect ke `index.php` + +### 3. Clear Browser Cache + +1. Clear cookies untuk domain `retribusi.btekno.cloud` +2. Clear cache browser +3. Hard refresh (Ctrl+Shift+R atau Cmd+Shift+R) + +### 4. Test Langsung + +Test dengan curl untuk melihat redirect chain: + +```bash +curl -I https://retribusi.btekno.cloud/index.php +``` + +Jika ada banyak `Location:` headers, berarti ada redirect loop di server. + +### 5. Cek Log Nginx + +```bash +tail -f /var/log/nginx/retribusi_error.log +``` + +Lihat apakah ada error atau redirect yang berulang. + +## Konfigurasi yang Benar + +### Nginx (Production) + +```nginx +server { + listen 80; + server_name retribusi.btekno.cloud; + + # Document root HARUS di folder public + root /www/wwwroot/retribusi.btekno.cloud/retribusi/public; + index index.php index.html; + + location / { + # Jangan redirect, langsung serve file + try_files $uri $uri/ =404; + } + + location ~ \.php$ { + fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} +``` + +### Apache (Production) + +```apache + + ServerName retribusi.btekno.cloud + DocumentRoot /www/wwwroot/retribusi.btekno.cloud/retribusi/public + + + Options -Indexes +FollowSymLinks + AllowOverride All + Require all granted + + +``` + +## Checklist + +- [ ] Document root di nginx/apache mengarah ke folder `public/` +- [ ] Tidak ada redirect di `.htaccess` di root +- [ ] `.htaccess` di `public/` tidak ada redirect (hanya security headers) +- [ ] Konfigurasi nginx tidak menggunakan `try_files ... /index.php` di root location +- [ ] Browser cache sudah di-clear +- [ ] Cookies sudah di-clear +