apache-unified-simple.conf 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <VirtualHost *:80>
  2. ServerName inventory.local
  3. DocumentRoot /var/www/html
  4. # Set proper directory index for frontend
  5. DirectoryIndex index.html index.php
  6. # Enable CORS headers for API requests
  7. Header always set Access-Control-Allow-Origin "*"
  8. Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
  9. Header always set Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With"
  10. Header always set Access-Control-Allow-Credentials "true"
  11. # Handle preflight requests
  12. RewriteEngine On
  13. RewriteCond %{REQUEST_METHOD} OPTIONS
  14. RewriteRule ^(.*)$ $1 [R=200,L]
  15. # API routes - handle PHP files in api directory
  16. <Directory "/var/www/html/api">
  17. Options -Indexes +FollowSymLinks
  18. AllowOverride All
  19. Require all granted
  20. # Handle PHP files
  21. <FilesMatch "\.php$">
  22. SetHandler application/x-httpd-php
  23. </FilesMatch>
  24. </Directory>
  25. # Root directory - serve frontend files and handle PHP
  26. <Directory "/var/www/html">
  27. Options -Indexes +FollowSymLinks
  28. AllowOverride All
  29. Require all granted
  30. # Handle PHP files
  31. <FilesMatch "\.php$">
  32. SetHandler application/x-httpd-php
  33. </FilesMatch>
  34. # Vue.js SPA routing - fallback to index.html for non-API, non-PHP requests
  35. RewriteEngine On
  36. RewriteBase /
  37. # Don't rewrite API requests
  38. RewriteCond %{REQUEST_URI} ^/api/
  39. RewriteRule ^ - [L]
  40. # Don't rewrite PHP files
  41. RewriteCond %{REQUEST_URI} \.php$
  42. RewriteRule ^ - [L]
  43. # Don't rewrite existing files/directories
  44. RewriteCond %{REQUEST_FILENAME} -f [OR]
  45. RewriteCond %{REQUEST_FILENAME} -d
  46. RewriteRule ^ - [L]
  47. # Fallback to index.html for Vue.js SPA
  48. RewriteRule . index.html [L]
  49. </Directory>
  50. # Security headers
  51. Header always set X-Content-Type-Options nosniff
  52. Header always set X-Frame-Options DENY
  53. Header always set X-XSS-Protection "1; mode=block"
  54. # Error handling
  55. ErrorLog ${APACHE_LOG_DIR}/error.log
  56. CustomLog ${APACHE_LOG_DIR}/access.log combined
  57. </VirtualHost>