Compare commits
2 Commits
b1fff97254
...
a6c5141920
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6c5141920 | ||
|
|
bd1fa7fba4 |
@ -4,7 +4,7 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"build": "next build && node scripts/copy-htaccess.cjs",
|
||||
"start": "next start",
|
||||
"lint": "eslint",
|
||||
"sitemap": "node scripts/generate-sitemap.cjs"
|
||||
@ -30,4 +30,4 @@
|
||||
"eslint-config-next": "16.0.3",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,36 +1,61 @@
|
||||
# Antalya Restaurant - Apache Configuration
|
||||
# Handles trailing slashes and prevents 403 errors
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
|
||||
# Allow Next.js static files and assets
|
||||
RewriteRule ^_next/ - [L]
|
||||
RewriteRule ^static/ - [L]
|
||||
# Force HTTPS (optional, uncomment if needed)
|
||||
# RewriteCond %{HTTPS} off
|
||||
# RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
|
||||
|
||||
# Serve existing files or directories directly
|
||||
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -d
|
||||
RewriteRule ^ - [L]
|
||||
# Handle trailing slashes
|
||||
# If a directory exists with the name, serve its index.html
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_URI} !(.*)/$
|
||||
RewriteCond %{REQUEST_FILENAME}/index.html -f
|
||||
RewriteRule ^(.*)$ $1/ [R=301,L]
|
||||
|
||||
# Redirect extensionless URLs to trailing slash directories
|
||||
# Works with "trailingSlash: true" and static export
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_URI} !/$
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}/index.html -f
|
||||
RewriteRule ^(.+)$ /$1/ [R=301,L]
|
||||
# Serve index.html for directories
|
||||
RewriteCond %{REQUEST_FILENAME} -d
|
||||
RewriteRule ^(.*)$ $1/index.html [L]
|
||||
|
||||
# Apache 404 (Next.js static export supports 404.html)
|
||||
ErrorDocument 404 /404.html
|
||||
# Specific rewrites for main pages (with and without trailing slash)
|
||||
RewriteRule ^about-antalya-restaurant/?$ about-antalya-restaurant/index.html [L]
|
||||
RewriteRule ^antalya-restaurant-menu/?$ antalya-restaurant-menu/index.html [L]
|
||||
RewriteRule ^antalya-restaurant-gallery/?$ antalya-restaurant-gallery/index.html [L]
|
||||
RewriteRule ^book-a-table/?$ book-a-table/index.html [L]
|
||||
RewriteRule ^catering-services-ontario/?$ catering-services-ontario/index.html [L]
|
||||
RewriteRule ^antalya-turkish-food-blog/?$ antalya-turkish-food-blog/index.html [L]
|
||||
|
||||
# Blog posts
|
||||
RewriteRule ^antalya-turkish-food-blog/([^/]+)/?$ antalya-turkish-food-blog/$1/index.html [L]
|
||||
|
||||
# Prevent directory listing
|
||||
Options -Indexes
|
||||
|
||||
# Custom error pages
|
||||
ErrorDocument 404 /404.html
|
||||
</IfModule>
|
||||
|
||||
# Security Headers
|
||||
<IfModule mod_headers.c>
|
||||
# Cache static assets aggressively
|
||||
<FilesMatch "\.(js|css|png|jpg|jpeg|gif|ico|svg|webp)$">
|
||||
Header set Cache-Control "public, max-age=31536000, immutable"
|
||||
</FilesMatch>
|
||||
|
||||
# HTML is not cached (important for updated content)
|
||||
<FilesMatch "\.(html)$">
|
||||
Header set Cache-Control "public, max-age=0, must-revalidate"
|
||||
</FilesMatch>
|
||||
Header set X-Content-Type-Options "nosniff"
|
||||
Header set X-Frame-Options "DENY"
|
||||
Header set X-XSS-Protection "1; mode=block"
|
||||
</IfModule>
|
||||
|
||||
# Cache Control
|
||||
<IfModule mod_expires.c>
|
||||
ExpiresActive On
|
||||
ExpiresByType image/jpg "access plus 1 year"
|
||||
ExpiresByType image/jpeg "access plus 1 year"
|
||||
ExpiresByType image/gif "access plus 1 year"
|
||||
ExpiresByType image/png "access plus 1 year"
|
||||
ExpiresByType image/webp "access plus 1 year"
|
||||
ExpiresByType image/svg+xml "access plus 1 year"
|
||||
ExpiresByType text/css "access plus 1 year"
|
||||
ExpiresByType text/javascript "access plus 1 year"
|
||||
ExpiresByType application/javascript "access plus 1 year"
|
||||
ExpiresByType image/x-icon "access plus 1 year"
|
||||
</IfModule>
|
||||
|
||||
18
scripts/copy-htaccess.cjs
Normal file
18
scripts/copy-htaccess.cjs
Normal file
@ -0,0 +1,18 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Copy .htaccess from public to out directory after build
|
||||
const source = path.join(__dirname, '..', 'public', '.htaccess');
|
||||
const destination = path.join(__dirname, '..', 'out', '.htaccess');
|
||||
|
||||
try {
|
||||
if (fs.existsSync(source)) {
|
||||
fs.copyFileSync(source, destination);
|
||||
console.log('✓ .htaccess copied to out directory');
|
||||
} else {
|
||||
console.warn('⚠ .htaccess not found in public directory');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error copying .htaccess:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
29
vercel.json
29
vercel.json
@ -1,34 +1,61 @@
|
||||
{
|
||||
"trailingSlash": true,
|
||||
"cleanUrls": false,
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "/about-antalya-restaurant",
|
||||
"destination": "/about-antalya-restaurant/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/about-antalya-restaurant/",
|
||||
"destination": "/about-antalya-restaurant/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/antalya-restaurant-menu",
|
||||
"destination": "/antalya-restaurant-menu/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/antalya-restaurant-menu/",
|
||||
"destination": "/antalya-restaurant-menu/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/antalya-restaurant-gallery",
|
||||
"destination": "/antalya-restaurant-gallery/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/antalya-restaurant-gallery/",
|
||||
"destination": "/antalya-restaurant-gallery/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/book-a-table",
|
||||
"destination": "/book-a-table/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/book-a-table/",
|
||||
"destination": "/book-a-table/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/catering-services-ontario",
|
||||
"destination": "/catering-services-ontario/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/catering-services-ontario/",
|
||||
"destination": "/catering-services-ontario/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/antalya-turkish-food-blog",
|
||||
"destination": "/antalya-turkish-food-blog/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/antalya-turkish-food-blog/",
|
||||
"destination": "/antalya-turkish-food-blog/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/antalya-turkish-food-blog/:slug",
|
||||
"destination": "/antalya-turkish-food-blog/:slug/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/antalya-turkish-food-blog/:slug/",
|
||||
"destination": "/antalya-turkish-food-blog/:slug/index.html"
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user