fix install script6

This commit is contained in:
Edmund Tan 2025-07-22 02:17:42 +08:00
parent cb8a83eb34
commit 19f86290ff
2 changed files with 70 additions and 7 deletions

View File

@ -1,20 +1,22 @@
# ZitiNexus Router Enrollment UI - Apache Configuration # ZitiNexus Router Enrollment UI - Apache Configuration
# This file helps serve assets correctly when document root is not set to /public/ # This file helps serve assets correctly when document root is not set to /public/
# Redirect to public directory for main pages
RewriteEngine On RewriteEngine On
# Serve assets directly from assets directory # Serve assets directly from assets directory (highest priority)
RewriteRule ^assets/(.*)$ assets/$1 [L] RewriteRule ^assets/(.*)$ assets/$1 [L]
# Redirect main pages to public directory # Serve root-level PHP files directly (for current setup)
RewriteRule ^$ public/index.php [L] RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^index\.php$ public/index.php [L] RewriteRule ^(index|dashboard)\.php$ $1.php [L]
RewriteRule ^dashboard\.php$ public/dashboard.php [L]
# Handle other requests # Fallback: redirect to public directory only if file doesn't exist in root
RewriteRule ^$ index.php [L]
# Handle other requests only if file doesn't exist in root
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/assets/
RewriteRule ^(.*)$ public/$1 [L] RewriteRule ^(.*)$ public/$1 [L]
# Security: Deny access to sensitive directories # Security: Deny access to sensitive directories

61
UI/test-assets.php Normal file
View File

@ -0,0 +1,61 @@
<?php
/**
* Simple test to verify asset paths and file existence
*/
echo "<h1>Asset Path Test</h1>";
// Test direct paths (for root-level access)
echo "<h2>Direct Asset Paths (Root Level Access)</h2>";
echo "<p><strong>CSS:</strong> assets/css/style.css</p>";
echo "<p><strong>JS:</strong> assets/js/app.js</p>";
// Check if files exist
echo "<h2>File Existence Check</h2>";
echo "<p><strong>CSS exists:</strong> " . (file_exists('assets/css/style.css') ? 'YES' : 'NO') . "</p>";
echo "<p><strong>JS exists:</strong> " . (file_exists('assets/js/app.js') ? 'YES' : 'NO') . "</p>";
// Test actual links
echo "<h2>Test Links</h2>";
echo '<p><a href="assets/css/style.css" target="_blank">Test CSS Link</a></p>';
echo '<p><a href="assets/js/app.js" target="_blank">Test JS Link</a></p>';
// Show current directory
echo "<h2>Current Directory Info</h2>";
echo "<p><strong>Current working directory:</strong> " . getcwd() . "</p>";
echo "<p><strong>Script filename:</strong> " . $_SERVER['SCRIPT_FILENAME'] . "</p>";
echo "<p><strong>Document root:</strong> " . $_SERVER['DOCUMENT_ROOT'] . "</p>";
// List assets directory
echo "<h2>Assets Directory Contents</h2>";
if (is_dir('assets')) {
echo "<ul>";
$files = scandir('assets');
foreach ($files as $file) {
if ($file !== '.' && $file !== '..') {
echo "<li>$file";
if (is_dir("assets/$file")) {
echo " (directory)";
$subfiles = scandir("assets/$file");
echo "<ul>";
foreach ($subfiles as $subfile) {
if ($subfile !== '.' && $subfile !== '..') {
echo "<li>$subfile</li>";
}
}
echo "</ul>";
}
echo "</li>";
}
}
echo "</ul>";
} else {
echo "<p>Assets directory not found!</p>";
}
// Test with HTML
echo "<h2>HTML Test</h2>";
echo '<div style="color: red; font-weight: bold;">This text should be red if CSS is not loading</div>';
echo '<link rel="stylesheet" href="assets/css/style.css">';
echo '<div class="btn btn-primary">This should be styled if CSS loads</div>';
?>