# 404 ERROR - FILES NOT FOUND TROUBLESHOOTING GUIDE

## 🚨 Problem
Getting 404 errors for edit-project.php and profile.php (or other files)

---

## ✅ QUICK FIX (2 minutes)

### Step 1: Run Diagnostic Tool

Visit in your browser:
```
https://yourdomain.com/project-planner/check_404.php
```

This will show you:
- ✅ Which files exist
- ❌ Which files are missing
- Current directory structure
- Possible causes

### Step 2: Based on Results

**If files show as MISSING:**
→ Upload them from the package (see Solution A below)

**If files EXIST but still 404:**
→ Check .htaccess configuration (see Solution B below)

---

## 📋 SOLUTION A: Files Are Missing

### Cause
Files weren't uploaded or are in wrong location

### Fix

**Via cPanel File Manager:**

1. **Login to cPanel** → File Manager
2. **Navigate to** public_html/project-planner/
3. **Upload missing files:**
   - Edit → Upload
   - Select: edit-project.php, profile.php, delete-project.php
   - Or upload entire package and extract

**Via FTP:**

1. **Connect via FTP client** (FileZilla, etc.)
2. **Navigate to** /public_html/project-planner/
3. **Upload missing files** from your computer
4. **Verify permissions:** 644 for PHP files

**Files That MUST Exist:**
```
project-planner/
├── edit-project.php      ← Edit project details
├── profile.php           ← User profile page
├── delete-project.php    ← Delete project handler
├── dashboard.php
├── create-project.php
├── project.php
├── add-task.php
├── upload-workplan.php
├── login.php
├── register.php
├── logout.php
├── index.php
├── config.php
└── ... (other files)
```

---

## 📋 SOLUTION B: Files Exist But Still 404

### Cause 1: .htaccess RewriteBase Issue

**Check .htaccess file:**

```apache
RewriteBase /project-planner/
```

**Should match your installation path:**
- If in root: `RewriteBase /`
- If in subfolder: `RewriteBase /project-planner/`
- If in subdomain: `RewriteBase /`

**Fix:**

1. Open .htaccess file
2. Find line: `RewriteBase /project-planner/`
3. Update to match your actual path
4. Save and test

### Cause 2: .htaccess Blocking Files

**Test by temporarily disabling .htaccess:**

1. Rename .htaccess to .htaccess.bak
2. Try accessing edit-project.php
3. If it works → .htaccess has problematic rules
4. Re-enable and fix specific rules

**Check for these problematic rules:**
```apache
# Don't block PHP files!
<FilesMatch "\.php$">
    Order Deny,Allow
    Deny from all
</FilesMatch>
```

If you see this, REMOVE it from main .htaccess (only keep in uploads/.htaccess)

### Cause 3: mod_rewrite Not Enabled

**Symptoms:**
- All pages show 404
- Only index.php works
- URLs with .php extension fail

**Fix:**

Contact your hosting provider and request:
```
Please enable mod_rewrite for my account
```

Or add to .htaccess:
```apache
<IfModule mod_rewrite.c>
    RewriteEngine On
    # ... other rules
</IfModule>
```

---

## 📋 SOLUTION C: Wrong Directory Structure

### Verify Your Installation Path

**Your URLs should look like:**

```
https://yourdomain.com/project-planner/edit-project.php
https://yourdomain.com/project-planner/profile.php
https://yourdomain.com/project-planner/dashboard.php
```

**NOT like:**
```
https://yourdomain.com/edit-project.php  ← Missing project-planner/
https://yourdomain.com/public_html/project-planner/edit-project.php  ← Wrong path
```

**Common Mistakes:**

1. **Files uploaded to wrong directory**
   - Should be: public_html/project-planner/
   - Not: public_html/www/project-planner/
   - Not: home/user/project-planner/

2. **BASE_URL mismatch in config.php**
   ```php
   // Must match actual URL!
   define('BASE_URL', 'https://yourdomain.com/project-planner/');
   ```

---

## 🔧 STEP-BY-STEP TROUBLESHOOTING

### Step 1: Verify Files Exist

**Via cPanel File Manager:**
1. Navigate to project-planner folder
2. Look for edit-project.php and profile.php
3. Check file size (should be > 0 bytes)

**Via SSH:**
```bash
cd /path/to/project-planner/
ls -la *.php | grep -E "(edit-project|profile)"
```

Should show:
```
-rw-r--r-- 1 user user 8688 ... edit-project.php
-rw-r--r-- 1 user user 13537 ... profile.php
```

### Step 2: Check File Permissions

**Correct permissions:**
- PHP files: 644 (rw-r--r--)
- Directories: 755 (rwxr-xr-x)

**Fix via cPanel:**
1. Right-click file → Change Permissions
2. Set to 644

**Fix via SSH:**
```bash
chmod 644 edit-project.php profile.php
chmod 755 css js includes uploads
```

### Step 3: Test Direct Access

Try accessing files directly in browser:
```
https://yourdomain.com/project-planner/edit-project.php?id=1
https://yourdomain.com/project-planner/profile.php
```

**If you get:**
- ✅ Login redirect → Files work! Just need to login
- ❌ 404 error → Files missing or path wrong
- ⚠️ Blank page → PHP error (enable DEBUG_MODE)

### Step 4: Check .htaccess

**View .htaccess file:**
```apache
# Project Planner - Apache Configuration

# Prevent directory browsing
Options -Indexes

# Enable URL rewriting
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /project-planner/   ← CHECK THIS LINE
    
    # Don't rewrite existing files
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # ... other rules
</IfModule>
```

**Key things to check:**
1. RewriteBase matches your path
2. No rules blocking .php files
3. mod_rewrite section exists

---

## 💡 COMMON SCENARIOS

### Scenario 1: Fresh Installation

**Files are missing because:**
- Package not fully extracted
- Only partial upload completed
- Files in wrong directory

**Solution:**
1. Download project-planner.tar.gz
2. Extract ALL files
3. Upload entire folder to public_html/
4. Run check_404.php to verify

### Scenario 2: After Update

**Files missing because:**
- Only updated some files, not all
- Old files deleted but new not uploaded

**Solution:**
1. Download latest package
2. Upload edit-project.php and profile.php
3. Don't delete old files first - overwrite instead

### Scenario 3: Moved Installation

**404 errors because:**
- BASE_URL in config.php not updated
- .htaccess RewriteBase not updated
- Links still point to old location

**Solution:**
1. Update config.php BASE_URL
2. Update .htaccess RewriteBase
3. Clear browser cache
4. Test with new URL

---

## 🔍 DIAGNOSTIC COMMANDS

### Check if files exist (via SSH):
```bash
cd /path/to/project-planner/
ls -la edit-project.php profile.php delete-project.php
```

### Check file permissions:
```bash
stat edit-project.php
# Should show: Access: (0644/-rw-r--r--)
```

### Check web server error log:
```bash
tail -f /path/to/error_log
# Or in cPanel: Errors → Error Log
```

### Test file accessibility:
```bash
curl -I https://yourdomain.com/project-planner/edit-project.php
# Should return: HTTP/1.1 302 Found (redirect to login)
# NOT: HTTP/1.1 404 Not Found
```

---

## 📞 WHEN TO CONTACT HOSTING SUPPORT

Contact your hosting provider if:

1. ✅ Files exist (confirmed via File Manager)
2. ✅ Permissions are correct (644)
3. ✅ .htaccess looks correct
4. ❌ Still getting 404 errors

Ask them to:
- Enable mod_rewrite
- Check Apache configuration
- Verify .htaccess is being processed
- Check for security modules blocking files

---

## ✅ VERIFICATION CHECKLIST

Files are working when:

- [ ] check_404.php shows all files exist
- [ ] Files have 644 permissions
- [ ] .htaccess RewriteBase matches installation path
- [ ] BASE_URL in config.php is correct
- [ ] Can access dashboard.php (redirects to login)
- [ ] Can access edit-project.php?id=1 (redirects to login)
- [ ] Can access profile.php (redirects to login)
- [ ] After login, Edit Project button works
- [ ] After login, Profile menu item works

---

## 🎯 QUICK CHECKLIST

Before doing anything else, verify:

1. [ ] Files uploaded from latest package
2. [ ] All files in project-planner/ directory
3. [ ] File permissions are 644
4. [ ] .htaccess RewriteBase is correct
5. [ ] config.php BASE_URL is correct
6. [ ] Can access other .php files (like dashboard.php)

---

## 📖 FILE LIST

**These files MUST exist for full functionality:**

Core Pages:
- ✅ index.php
- ✅ login.php
- ✅ register.php
- ✅ logout.php
- ✅ dashboard.php
- ✅ create-project.php
- ✅ edit-project.php         ← Getting 404?
- ✅ delete-project.php
- ✅ project.php
- ✅ add-task.php
- ✅ upload-workplan.php
- ✅ profile.php              ← Getting 404?

Configuration:
- ✅ config.php
- ✅ .htaccess

Support Files:
- ✅ setup_admin.php
- ✅ test_upload.php
- ✅ check_404.php (this diagnostic)

---

## 🔒 SECURITY NOTE

After fixing 404 errors, delete diagnostic files:
- ✅ check_404.php
- ✅ test_upload.php (if not needed)
- ✅ setup_admin.php (after setup)

---

## 📝 EXAMPLE: Complete Upload Process

1. **Download package:**
   - project-planner.tar.gz

2. **Extract locally:**
   - Get all files from archive

3. **Upload via cPanel:**
   - File Manager → public_html/
   - Upload → project-planner folder
   - Or upload .tar.gz and extract

4. **Verify:**
   - Visit check_404.php
   - Should show all files exist

5. **Test:**
   - Login to application
   - Click "Edit Project" → Should work
   - Click profile menu → Should work

6. **Clean up:**
   - Delete check_404.php

---

**Still having issues? Run check_404.php and send screenshot of results for further help.**
