How do I integrate Prerender with Apache?
Make your JavaScript site fully readable by AI crawlers and search engines by adding Prerender rewrite rules to your Apache server.
TL;DR
Integrate Prerender with your Apache server by enabling five Apache modules, adding a configuration block to your vhost, and adding rewrite rules to your .htaccess file. You'll need .htaccess access and permission to enable modules via a2enmod. The integration takes about 20–30 minutes, and one Apache restart at the end applies all the changes.
ℹ️ Not sure which integration fits your stack? Ask Nexus, your AI integration assistant in your Prerender dashboard — describe your setup and Nexus will recommend the right approach and walk you through it.
Step 1: Open your Prerender dashboard and copy your token
- Log in to your Prerender dashboard.
- Go to Security and Access and copy your Prerender token.
ℹ️ Don't have a Prerender account yet? Sign up at prerender.io before continuing.
You'll replace the YOUR_TOKEN placeholder with this token in Step 4.
Step 2: Enable the required Apache modules
Prerender's Apache integration requires five modules: headers, proxy, proxy_http, ssl, and rewrite.
On Ubuntu and other Debian-based systems, run:
sudo a2enmod headers
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod ssl
sudo a2enmod rewrite
httpd.conf:LoadModule headers_module libexec/apache2/mod_headers.so
LoadModule proxy_module libexec/apache2/mod_proxy.so
LoadModule proxy_http_module libexec/apache2/mod_proxy_http.so
LoadModule ssl_module libexec/apache2/mod_ssl.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
ℹ️ Some modules may already be enabled. You'll restart Apache in Step 5 — that single restart applies both the module changes and the configuration changes you'll make in Steps 3 and 4.
Step 3: Update your Apache vhost configuration
Back up your Apache vhost config file before editing.
Add the following lines to the bottom of your vhost config inside the 443 block. The full Apache config source is available on GitHub if you need it.
# === Prerender.io Configuration ===
# Enable proxying over HTTPS
SSLProxyEngine on
# The lines below disable SSL certificate verification.
# Only uncomment these if you're testing with a local Prerender server using a self-signed certificate.
# For the hosted Prerender service, these should remain commented as it uses a valid SSL certificate.
# SSLProxyCheckPeerName off
# SSLProxyVerify none
Step 4: Add the rewrite rules to your .htaccess file
Back up your .htaccess file before editing. It's usually located in your site's root directory.
Add the following code at the very top of the file, replacing YOUR_TOKEN with the Prerender token you copied in Step 1.
# Change YOUR_TOKEN to your prerender token
# Change https://service.prerender.io/ (at the end of the last RewriteRule)
# to http://localhost:3000/ when testing with a local prerender server
<IfModule mod_headers.c>
RequestHeader set X-Prerender-Token "YOUR_TOKEN"
RequestHeader set X-Prerender-Version "prerender-apache@2.0.0"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
<IfModule mod_proxy_http.c>
RewriteCond %{HTTP_USER_AGENT} googlebot|adsbot-google|apis-google|mediapartners-google|google-safety|feedfetcher-google|googleproducer|google-site-verification|bingbot|yandexbot|yabrowser|yahoo|baiduspider|naver|seznambot|sznprohlizec|qwantbot|ecosia|duckduckbot|duckassistbot|applebot|facebookexternalhit|facebookcatalog|facebookbot|meta-externalagent|instagram|twitterbot|linkedinbot|whatsapp|slackbot|pinterest|pinterestbot|tiktok|tiktokspider|bytespider|discordbot|semrushbot|ahrefsbot|chrome-lighthouse|screaming-frog|oncrawlbot|botifybot|deepcrawl|lumar|rogerbot|dotbot|gptbot|chatgpt|oai-searchbot|chatgpt-user|claudebot|google-extended|perplexitybot|perplexity-user|youbot|amazonbot|anthropic-ai|claude-web|ccbot|mistralai-user|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest\/0\.|vkShare|W3C_Validator|redditbot|flipboard|tumblr|bitlybot|skypeuripreview|nuzzel|google\ page\ speed|qwantify|bitrix\ link\ preview|xing-contenttabreceiver|google-inspectiontool|telegrambot [NC,OR]
RewriteCond %{QUERY_STRING} _escaped_fragment_
RewriteCond %{REQUEST_URI} ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff|\.svg))
RewriteRule ^(index\.html|index\.php)?(.*) https://service.prerender.io/%{REQUEST_SCHEME}://%{HTTP_HOST}/$2 [P,END]
</IfModule>
</IfModule>
⚠️ These rules must be at the very top of your .htaccess file. Any existing rewrite rule above them that uses the [L] (last) flag will stop further processing and prevent Prerender from handling requests. See Troubleshooting Apache .htaccess integration if you run into conflicts with existing rules.
Step 5: Restart Apache
Restart Apache to apply all your configuration changes:
service apache2 restart
service httpd restart
Step 6: Verify your integration
Confirm that Prerender is correctly intercepting crawler requests and serving rendered HTML before you consider the setup complete.
Follow the steps in How do I verify my Prerender integration? to test your setup.
✅ Your integration is working when cached pages appear in your Prerender dashboard within a few minutes of your first crawler request, and Prerender response headers are visible in the verification tool.
If you don't see Prerender headers or IDs in the verification output, the integration is not active. Check that your rewrite rules are at the very top of .htaccess, that YOUR_TOKEN has been replaced with your actual token, and that all five Apache modules are enabled.
If you see "Prerender Integration Not Detected," follow the steps in What should I do if I receive a "Prerender Integration Not Detected" error? to resolve it.
💬 Still need help?
If you're running into issues with your Apache integration, our support team can help you diagnose what's going wrong.
→ Contact us at support@prerender.io