Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 Yesterday 23:04:09

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 236
Website Mastodon

Apache: redirecting deep links

I have a list of publications, some of which have links to locally stored PDF files. Crawlers deep link to those files and serve them directly, which I would like to gently redirect. The publications URL sets a cookie (“bot”) to a number. So, my .htaccess file looks like

RewriteCond %{HTTP_COOKIE}              !"bot=\d*"
RewriteRule "\.pdf$"                    publications

This doesn’t work. It’s supposed to serve up the publications Txp section static page. Even when the cookie is set, the PDF is returned. It returns the PDF even if I take out the cookie RewriteCond. What am I doing dumb?

Offline

#2 Today 03:36:36

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,239
Website GitHub Mastodon Twitter

Re: Apache: redirecting deep links

Can you post a sample link the crawlers use?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 Today 08:04:54

etc
Developer
Registered: 2010-11-11
Posts: 5,456
Website GitHub

Re: Apache: redirecting deep links

The standard txp .htaccess file contains these rules:

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.+) - [PT,L]

which mean that if a file/dir exists, it will be served directly, stopping (via [L] flag) processing other rules. Might it be interfering with your block?

Offline

Board footer

Powered by FluxBB