Our team recently built the website for our outdoor activity business near Marrakech (quad biking, buggy tours and camel rides). The brief sounded simple:
- it must rank on Google for very local keywords;
- customers must be able to book online;
- we need a dashboard to confirm or refuse bookings;
- everything must run on a cheap shared hosting plan (Hostinger, LiteSpeed, PHP, MySQL). No Node server and no VPS.
Here is the architecture we ended up with, the traps we fell into, and what we would do differently.
1. The stack
- Front end: React 19, TanStack Router, Tailwind CSS 4, Vite
- Rendering: static site generation (SSG) with a custom prerender script
- Back end: a few plain PHP 8.3 files + MySQL (PDO)
- Hosting: shared LiteSpeed server with a CDN in front
Browser ──► CDN ──► LiteSpeed ├── /index.html, /activites/…/index.html (prerendered React) ├── /api/reserver.php, /api/devis.php (bookings, quotes) └── /admin/index.php (owner dashboard) The idea: everything a search engine reads is static HTML, and the only dynamic parts are two API endpoints and a small admin page.
2. Why static generation instead of a plain SPA
With a classic single-page app, every URL returns the same empty index.html and the content only appears once JavaScript runs. Google can render JavaScript, but rendering is deferred and less reliable, and a lot of other crawlers (Bing, AI assistants, link previews) don't run JS at all.
So the build has a second step. After vite build, a prerender script visits every route and writes a real HTML file for each one:
// scripts/prerender.ts (simplified) for (const route of routes) { const html = await renderRoute(route.path); // React → HTML string const file = path.join('dist', route.path, 'index.html'); await fs.mkdir(path.dirname(file), { recursive: true }); await fs.writeFile(file, injectHead(html, route.meta)); } Each page gets its own <title>, meta description, canonical URL, hreflang links (French and English versions) and JSON-LD. React then hydrates on top, so the site still feels like an app.
The same script also generates the sitemap.xml (with hreflang), robots.txt, an llms.txt file for AI crawlers, and the .htaccess rules. One source of truth, no hand-edited SEO files.
3. Structured data generated from the content
The activities (duration, distance, price per person, languages, meeting point) already live in TypeScript data files. Instead of writing JSON-LD by hand, we generate it from that same data:
function touristTrip(a: Activite) { return { '@context': 'https://schema.org', '@type': 'TouristTrip', name: a.titre, description: a.resume, provider: { '@id': `${SITE}/#organisation` }, offers: { '@type': 'Offer', priceCurrency: 'MAD', price: a.prix, priceSpecification: { '@type': 'UnitPriceSpecification', price: a.prix, priceCurrency: 'MAD', referenceQuantity: { '@type': 'QuantitativeValue', value: 1, unitText: 'person' }, }, }, }; } The same approach produces TravelAgency (organisation), FAQPage, BreadcrumbList, and Person + ProfilePage for the guides who sign the articles. When a price changes, the page, the structured data and the booking API all change together.
The build also writes the prices to a JSON file that the PHP side reads (see below), so the front end and the back end can never disagree.
4. Bookings without a heavy back end
The booking form POSTs to /api/reserver.php. A few rules we followed:
Never trust the price sent by the browser. The client only sends the activity, the date, the time slot and the number of people. The server recalculates the total from the JSON generated at build time:
$tarifs = json_decode(file_get_contents(__DIR__ . '/_lib/tarifs.json'), true); $activite = $tarifs[$data['activite']] ?? null; if (!$activite) { http_response_code(422); exit(json_encode(['ok' => false, 'champs' => ['activite']])); } $total = $activite['prix'] * max(1, (int) $data['participants']); A honeypot instead of a CAPTCHA. The form has a hidden site_web field that humans never fill. Bots usually do:
if (!empty($_POST['site_web'])) { http_response_code(201); // pretend it worked exit(json_encode(['ok' => true])); } Together with an Origin check and strict validation, this has been enough so far, with no friction for real customers.
Keep secrets out of the web root. The config file (database credentials, mail settings) lives one level above public_html, so it can never be downloaded by mistake:
$config = require dirname(__DIR__, 3) . '/reservations-config.php'; And the _lib folder inside the API has its own .htaccess:
Require all denied If the API fails, don't lose the customer. If the request fails (server error, network issue), the front end switches to a fallback screen that pre-fills a WhatsApp message with the booking summary. In our market, a lot of customers prefer WhatsApp anyway.
After a successful booking, PHP mail() sends a multipart (HTML + text) email to the customer and a notification to us. Confirming the booking in the dashboard sends a second email with an "add to Google Calendar" link.
5. The admin dashboard
/admin/index.php is one PHP file:
- a single account, whose password is created on the first visit using a one-time installation key;
- the session cookie is limited to
/admin/, and every action is protected by a CSRF token; - logins are limited to 5 attempts per 15 minutes;
- actions: confirm, refuse, cancel, add a note, delete (with an explicit confirmation checkbox), and export to CSV;
-
X-Robots-Tag: noindexandCache-Control: no-storeheaders.
No framework, and it's easy to audit.
6. The trap: a redirect loop on LiteSpeed
This one cost us an evening. Our .htaccess removed trailing slashes to keep URLs clean:
RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ /$1 [R=301,L] But LiteSpeed (like Apache's mod_dir) adds a trailing slash when the URL matches a real directory. /admin → /admin/ → /admin → … ERR_TOO_MANY_REDIRECTS.
Even worse, the first broken version used a 301, so Chrome cached the redirect and kept looping even after we fixed the server.
What fixed it:
DirectorySlash Off # Send the admin to an explicit file, with a temporary redirect RewriteRule ^admin/?$ /admin/index.php [R=302,L] # Strip trailing slashes everywhere except the admin RewriteCond %{REQUEST_URI} !^/admin/ RewriteRule ^(.+)/$ /$1 [R=301,L] Lessons:
- Use 302 while you're still testing a redirect. Only switch to 301 when you're sure.
- On shared hosting, an explicit file path (
/admin/index.php) is simpler than fighting the directory index. - When testing redirects, use a private window and purge the CDN.
7. Results
A few days after launch, Google Search Console shows:
- the sitemap was read successfully, with 38 URLs discovered (French + English);
- 0 non-HTTPS pages;
- breadcrumb structured data valid on every page, with no errors;
- the main activity pages are already indexed.
Not spectacular numbers, but a clean technical base for a brand-new domain is exactly what you want before working on content and links.
8. What we would do differently
- Start with 302 redirects, always. (See above.)
- Generate the
.htaccessfrom code from day one. Hand-edited rewrite rules are where bugs hide. - Plan the content model for SEO first. Having durations, distances and prices as structured data from the start is what made JSON-LD, the sitemap and the booking prices trivial to keep in sync.
- Test with the real host early. Apache in Docker on a laptop is not LiteSpeed behind a CDN.
You don't need a big framework or an expensive server to build a fast, well-indexed booking website. Static HTML for everything public, a few small PHP files for what must be dynamic, and a build step that generates the boring SEO files for you.
The live result: activites-agafay.com.
Questions about the prerender script or the LiteSpeed setup? Ask in the comments.