I’m having trouble getting navigation links to work. I think it’s related to base_url and I’m wondering if you can point me to a place where I can change base_url so that it captures server name?
== Background ==
In order to make tags for taxonomylist, archive and blog items to work on my Grav 0.9.6 with Nginx, I modified base_url similar to “{{ base_url_relative}} is empty” post.
== Details ==
- In “user/themes/antimatter/templates/partials/blog_item.html.twig” I changed
<a href="{{ base_url }}/tag:{{ tag }}">{{ tag }}</a>
to<a href="{{ base_url == '' ? '/' : base_url_relative }}/tag:{{ tag }}">{{ tag }}</a>
.
NOTE: I had to do that in Antimatter v1.1.8 – In Antimatter v1.1.11, I don’t have to modify blog_item.html.twig.
-
In “user/plugins/taxonomylist/templates/taxonomylist.html.twig” changed to
<a href="{{ base_url == '' ? '/' : base_url_relative }}/tag:{{ tax|e('url') }}">{{ tax }}</a>
-
In “user/plugins/archives/templates/partials/archives.html.twig” changed to
<a href="{{ base_url == '' ? '/' : base_url_relative }}/month:{{ month|date('M _Y')|lower|e('url') }}">
The only outstanding item left in my setup is page navigation at the bottom of the (home) page. For example, for my Grav server name I use “sub.localhost” – For page 2, instead of “sub.localhost:port/page:2” the link at the bottom of the page is just “page:2”.
I placed a test.php in my Grav root directory containing: <pre><?php var_export($_SERVER)?></pre>
. Output when with a web browser I request “sub.localhost/test.php/foo/bar.php?v=1”:
array (
'USER' => 'www',
'HOME' => '/var/www',
'FCGI_ROLE' => 'RESPONDER',
'SCRIPT_FILENAME' => '/grav/test.php',
'PATH_INFO' => '/foo/bar.php',
'PATH_TRANSLATED' => '/grav/foo/bar.php',
'QUERY_STRING' => 'v=1',
'REQUEST_METHOD' => 'GET',
'CONTENT_TYPE' => '',
'CONTENT_LENGTH' => '',
'SCRIPT_NAME' => '/test.php',
'REQUEST_URI' => '/test.php/foo/bar.php?v=1',
'DOCUMENT_URI' => '/test.php/foo/bar.php',
'DOCUMENT_ROOT' => '/grav',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SERVER_SOFTWARE' => 'nginx/1.6.0',
'REMOTE_ADDR' => '10.0.2.2',
'REMOTE_PORT' => '63736',
'SERVER_ADDR' => '10.0.2.15',
'SERVER_PORT' => '80',
'SERVER_NAME' => 'sub.localhost',
'REDIRECT_STATUS' => '200',
'HTTP_HOST' => 'sub.localhost:7890',
'HTTP_CONNECTION' => 'keep-alive',
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*; q=0.8',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Iron/37.0.2000.0 Chrome/37.0.2000.0 Safari/537.36',
'HTTP_DNT' => '1',
'HTTP_ACCEPT_ENCODING' => 'gzip,deflate,sdch',
'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8',
'PHP_SELF' => '/test.php/foo/bar.php',
'REQUEST_TIME_FLOAT' => 1416732931.3755169,
'REQUEST_TIME' => 1416732931,
)