Skip to content
● Critical PHP security fixes are out: update PHP on your Grav sites. What to do →

Install grav in a secondary directory

solved

Started by Gino 9 years ago · 10 replies · 2112 views
9 years ago

Hi,
I need to install grav in a secondary directory.
I tried different ways but nothing.
Where and what I have to change?
Everytime grav system get out a terrible error 404...

Help, please!

9 years ago

The same problem.
GRAV installed in the subfolder "html/demo"
"html" - is root hosting folder, like "www", "public" etc.
Index page at "http://domen.com/demo" opens successfully.
In main menu the absolute links like "/blog", "/services", etc.
The links works "http://domen.com/blog", "http://domen.com/services"
instead "http://domen.com/demo/blog", "http://domen.com/demo/services". I tried to change the site URL in system.yaml and htaccess, the routing from admin-panel. I think it's a simple task, but I can't solve it. I tried a lot of options reading the documentation.

9 years ago

Have you also tried setting 'Custom base URL' setting in the system configuration?

47%20PM|690x65

9 years ago

{% macro nav_loop(page) %}
{% for p in page.children.visible %}
{% set active_page = (p.active or p.activeChild) ? 'active' : '' %}
{% if p.children.visible.count > 0 %}
<li>
<a href="{{ p.url }}" class="{{ active_page }}">
{{ p.menu }}
</a>
<ul>
{{ _self.nav_loop(p) }}
</ul>
</li>
{% else %}
<li>
<a href="{{ p.url }}" class="{{ active_page }}">
{{ p.menu }}
</a>
</li>
{% endif %}
{% endfor %}
{% endmacro %}

<ul {{ tree ? 'class="tree"' : '' }}>
{{ _self.nav_loop(pages) }}
</ul>

9 years ago

But I'm using absolute links in menu, like: <li class="nav-item ">

HTML
                    <a class="nav-link" href="/blog">Blog</a>
                </li>
                <li class="nav-item ">
                    <a class="nav-link" href="/forms/contact">Contact</a>
                </li>
9 years ago

Alright. Just update the links like so -

TWIG
<a class="nav-link" href="{{ base_url }}/blog">Blog</a>
👍 1

Suggested topics

Topic Participants Replies Views Activity
Installation & Hosting · by David Meissner, 17 hours ago
0 26 17 hours ago
Installation & Hosting · by David Meissner, 1 day ago
0 39 1 day ago
Installation & Hosting · by Anthony J Cervo, 6 days ago
3 123 4 days ago
Installation & Hosting · by motorambler, 2 months ago
9 798 4 weeks ago
Installation & Hosting · by jeremycherfas, 1 month ago
1 402 1 month ago