I try to configure an Apache server to add an HTTP Link header pointing at a Memento TimeGates url
My htaccess:
RewriteEngine on
RewriteCond %{IS_SUBREQ} false
RewriteRule ^/(.*) - [E=ORIGURI:%{HTTP_HOST}/$1]
RewriteRule ^/(.*) - [E=ORIGQRY:]
RewriteCond %{QUERY_STRING} .+
RewriteRule ^/(.*) - [E=ORIGQRY:?%{QUERY_STRING}]
RewriteRule ^/(.*) - [E=ORIGPROTO:http]
RewriteCond %{HTTPS} on
RewriteRule ^/(.*) - [E=ORIGPROTO:https]
Header always set Link
"<http://purl.org/memento/timegate/%{ORIGPROTO}e://%{ORIGURI}e%{ORIGQRY}e>;rel=timegate"
.
.
.
unchanged from: http://www.mementoweb.org/tools/apache/
I am testing the code on XAMPP server but the response sent by the server is:
.
.
.
Link <http://purl.org/memento/timegate/(null)://(null)(null)>;rel=timegate
Server Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7
.
.
.
What is wrong with the htaccess?
EDIT 1
Removing the leading slashes as suggested by Jon Lin :
RewriteEngine On
RewriteCond %{IS_SUBREQ} FALSE
RewriteRule ^(.*) - [E=ORIGURI:$1]
RewriteRule ^(.*) - [E=ORIGQRY:]
RewriteCond %{QUERY_STRING} .+
RewriteRule ^(.*) - [E=ORIGQRY:?%{QUERY_STRING}]
RewriteRule ^(.*) - [E=ORIGPROTO:http]
RewriteCond %{HTTPS} on
RewriteRule ^(.*) - [E=ORIGPROTO:https]
Header always set Link "<http://purl.org/memento/timegate/%{ORIGPROTO}e://%{ORIGURI}e%{ORIGQRY}e>;rel=timegate"
The new response sent by the server:
Link <http://purl.org/memento/timegate/http://(null)>;rel=timegate
As we can see the protocole is parsed but not the rest of the url, any other suggestion?
Configuring an Apache server for Memento
1. HTTP Headers Using .htaccess
See: htaccess - how to capture the current rewrited url?
2. HTTP Headers Using PHP
Resources: http://moz.com/blog/how-to-advanced-relcanonical-http-headers