JarvisAEO/SEOHelpdeskMarketingCRM

WordPress Integration

Serve your AEO blog at yourdomain.com/blog on WordPress using the Rewrite strategy.

This uses the Rewrite integration strategy: a /blog folder in your WordPress root intercepts requests and reverse-proxies them to AEO. Three steps. Replace {brand_slug} with your own brand slug in index.php.

1

Install a file-manager plugin

Install a plugin that lets you edit files from the WordPress admin, for example WP File Manager (https://vi.wordpress.org/plugins/wp-file-manager/).

2

Create a blog folder inside public_html

Open the file manager and create a new folder named "blog" inside public_html.

3

Add these two files inside /blog

File name: .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /blog/index.php [L]

File name: index.php

<?php
/**
 * AEO Blog Proxy — reverse proxy /blog to AEO platform
 */
$path = parse_url($_SERVER['REQUEST_URI'] ?? '/blog', PHP_URL_PATH);
$target = 'https://app.aeo.how/{brand_slug}' . $path;

if (!empty($_SERVER['QUERY_STRING'])) {
  $target .= '?' . $_SERVER['QUERY_STRING'];
}

$ch = curl_init($target);
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_MAXREDIRS => 5,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HEADER => true,
  CURLOPT_SSL_VERIFYPEER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_HTTPHEADER => [
    'X-Forwarded-Host: ' . ($_SERVER['HTTP_HOST'] ?? ''),
    'X-Forwarded-Proto: https',
    'X-Forwarded-For: ' . ($_SERVER['REMOTE_ADDR'] ?? ''),
    'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Accept-Language: ' . ($_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? 'vi,en;q=0.5'),
    'User-Agent: ' . ($_SERVER['HTTP_USER_AGENT'] ?? 'AEO-Blog-Proxy/1.0'),
  ],
]);

$response = curl_exec($ch);

if (curl_errno($ch)) {
  curl_close($ch);
  http_response_code(502);
  echo 'Blog temporarily unavailable.';
  exit;
}

$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers_raw = substr($response, 0, $header_size);
$body = substr($response, $header_size);
curl_close($ch);

http_response_code($http_code);

$safe = ['Content-Type', 'Cache-Control', 'ETag', 'Last-Modified', 'X-Robots-Tag'];
foreach (explode("\r\n", $headers_raw) as $line) {
  foreach ($safe as $allowed) {
    if (stripos($line, $allowed . ':') === 0) {
      header($line);
      break;
    }
  }
}

$body = str_replace('/{brand_slug}/blog', '/blog', $body);
echo $body;

Replace {brand_slug} with your own brand slug in both the $target URL and the str_replace line near the bottom.

WordPress Integration | Jarvis AEO/SEO Help