2

I would like to have this new prerendering service I'm using NOT apply its magic to the homepage and basically only to pages that begin with https://thechartcast.com/episodes/. Below is the relevant section of htaccess that controls the URL rewrites for the service. I am kind of nervous about attempting myself, so if someone could help through how to write such an exception, that would be awesome.

<IfModule mod_rewrite.c>
    RewriteEngine On
    <IfModule mod_proxy_http.c>
        RewriteCond %{HTTP_USER_AGENT} googlebot|bingbot|yandex|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp [NC,OR]
        RewriteCond %{QUERY_STRING} _escaped_fragment_
        RewriteCond %{HTTP:X-Prerender} !1
        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)?(.*) http://service.prerender.io/https://thechartcast.com/$2 [P,END]
    </IfModule>
</IfModule>
2

You could add another condition to the top of the list of conditions. For example:

RewriteCond %{REQUEST_URI} ^/episodes/
RewriteCond %{HTTP_USER_AGENT} ....
:

The RewriteRule that follows will then only be applied when the requested URL starts with /episodes/.

1

You could change

RewriteRule ^(index\.html|index\.php)?(.*)

to

RewriteRule ^(index\.html|index\.php)?(episodes/.*)

So that it only matches that directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.