# How to get a URL from a subpage

**URL:** <https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898>\
**Category:** Questions\
**Tags:** v3\
**Created:** [February 15, 2019, 12:37pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898 "2019-02-15T12:37:36Z")\
**Posts on this page:** 15\
**Page:** 2

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 15, 2019, 4:21pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/21 "2019-02-15T16:21:32Z")

</div>

That was not the question. I wanted to know the URL of your homepage.

---

<div class="post-metadata">

**Author:** ![exeldoc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/exeldoc/32/6224_2.png) [@exeldoc](https://forum.getkirby.com/u/exeldoc)\
**Post date:** [February 15, 2019, 4:47pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/22 "2019-02-15T16:47:06Z")

</div>

> [@texnixe](#):
>
> I wanted to know the URL of your homepage.

for testing i uploaded it here:  
`http://simpson_johnson.alexanderboenninger.de/legal_notice`  
unfortunatly, does not even show the error page

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 15, 2019, 4:51pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/23 "2019-02-15T16:51:29Z")

</div>

You don’t want to answer my question, do you?

In any case, there is something not working with your URL rewriting. The generated URL is fine on your remote server. On the remote server, you might have to set the RewriteBase in your `.htaccess`, probably to `/`.

But that doesn’t explain why it doesn’t work as expected locally, because in a Mamp environment, you usually don’t have to make any modifications to the `.htaccess`. But maybe it is ignored due to your Apache settings (or are you using Nginx locally?).

---

<div class="post-metadata">

**Author:** ![exeldoc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/exeldoc/32/6224_2.png) [@exeldoc](https://forum.getkirby.com/u/exeldoc)\
**Post date:** [February 15, 2019, 5:18pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/24 "2019-02-15T17:18:11Z")

</div>

> [@texnixe](#):
>
> You don’t want to answer my question, do you?

Sry. i tryed. but i don’t know which URL could mean, after those i gave you. 😬  
So which URL do you want to know?

well, i used node for an other projekt recently. Not shure if that can effect the kirby structure.  
So you think i have to change something in the `.htaccess` – there is nothing written about RewriteBase just mod\_rewirte.  
here what it says:

```
As-MacBook-Pro:~ a$ /Users/a/path/starterkit-master/.htaccess ; exit;
/Users/a/path/starterkit-master/.htaccess: line 4: syntax error near unexpected token `newline'
/Users/a/path/starterkit-master/.htaccess: line 4: `<IfModule mod_rewrite.c>'
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...40 completed.

[Prozess beendet]

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 15, 2019, 5:22pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/25 "2019-02-15T17:22:36Z")

</div>

> [@exeldoc](#):
>
> Sry. i tryed. but i don’t know which URL could mean, after those i gave you. 😬  
> So which URL do you want to know?

I meant the URL of your home page, assuming that the homepage of your local project works. The full URL you see in your browser’s address bar with the home page open on localhost.

---

<div class="post-metadata">

**Author:** ![exeldoc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/exeldoc/32/6224_2.png) [@exeldoc](https://forum.getkirby.com/u/exeldoc)\
**Post date:** [February 15, 2019, 5:47pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/26 "2019-02-15T17:47:15Z")

</div>

Now i am embarrassed. 😂  
maybe now i unterstood.

when i just start the site: this is standing in the adressbar:

 ![46](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/b/b487732f3012900d120c76fd985c102f20a51952.png)

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 15, 2019, 6:20pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/27 "2019-02-15T18:20:04Z")

</div>

Yep, that’s all I wanted to know. So the URL for the page is fine.

But as we can see, subpages are not working.

Since the `.htaccess` file is there, let’s see if it works at all. Put some random characters at the top of the file and save. If your site breaks, that’s a good sign.

If not, are you using Apache at all? Or Nginx?

---

<div class="post-metadata">

**Author:** ![exeldoc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/exeldoc/32/6224_2.png) [@exeldoc](https://forum.getkirby.com/u/exeldoc)\
**Post date:** [February 15, 2019, 6:34pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/28 "2019-02-15T18:34:16Z")

</div>

Yeah. Now the site is not working at all.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 15, 2019, 6:42pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/29 "2019-02-15T18:42:17Z")

</div>

Perfect. Then that works as expected as well. You can now undo this.

Do you redirect to the error page anywhere in your templates (`go('error')`)?

---

<div class="post-metadata">

**Author:** ![exeldoc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/exeldoc/32/6224_2.png) [@exeldoc](https://forum.getkirby.com/u/exeldoc)\
**Post date:** [February 15, 2019, 6:58pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/30 "2019-02-15T18:58:06Z")

</div>

> [@texnixe](#):
>
> ( `go('error')` )

Yes in the default.php.  
A few weeks ago i build the onepager according to this description: [One-pager site | Kirby CMS](https://getkirby.com/docs/cookbook/content-structure/one-pager)

---

<div class="post-metadata">

**Author:** ![exeldoc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/exeldoc/32/6224_2.png) [@exeldoc](https://forum.getkirby.com/u/exeldoc)\
**Post date:** [February 15, 2019, 7:04pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/31 "2019-02-15T19:04:01Z")

</div>

OK. I just removed it from the default, now it is working.

I am really sorry, it is my first kirby project. 🎉  
What a day. Thanks for your wonderfull support!

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 15, 2019, 7:12pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/32 "2019-02-15T19:12:54Z")

</div>

I suggest you use a different template than the default template for the legal notice and other pages you want to access, but keep the redirect to the error page in the `default.php` template.

You can achieve this by creating a new template and giving the text file in the `legal_notice` folder the same name as this new template, e.g. `/site/templates/legal_notice.php` and `/content/legal_notice/legal_notice.txt`

---

<div class="post-metadata">

**Author:** ![exeldoc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/exeldoc/32/6224_2.png) [@exeldoc](https://forum.getkirby.com/u/exeldoc)\
**Post date:** [February 15, 2019, 7:29pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/33 "2019-02-15T19:29:26Z")

</div>

> [@texnixe](#):
>
> You can achieve this by creating a new template and giving the text file in the `legal_notice` folder the same name as this new template, e.g. `/site/templates/legal_notice.php` and `/content/legal_notice/legal_notice.txt`

Oh, but that is how i have already done it. see the screenshots from before. (post#9)  
And right now it is not working, when in the dafault.php redirect to the error page…

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 15, 2019, 7:33pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/34 "2019-02-15T19:33:31Z")

</div>

I saw the template, but have you checked if your text file also has the correct name? Kirby falls back to the default.php template only if it cannot find a template that fits the content file name. Can you show me what is in the `/content/0_legal_notice` folder?

---

<div class="post-metadata">

**Author:** ![exeldoc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/exeldoc/32/6224_2.png) [@exeldoc](https://forum.getkirby.com/u/exeldoc)\
**Post date:** [February 15, 2019, 7:45pm UTC](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898/35 "2019-02-15T19:45:13Z")

</div>

![10](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/6/6ca5d45413971309859b28e23952a7c0ee4f2bad.png)  
But somehow it is working now. Also with the `go ("error")` in `default.php`.

[Previous page](https://forum.getkirby.com/t/how-to-get-a-url-from-a-subpage/12898.md?page=1)
