具有多个 GET 变量的 PHP 导航

发布于 2024-10-09 20:33:17 字数 638 浏览 0 评论 0原文

几周来我一直在绞尽脑汁试图找到进行 php 导航的理想方法。

(理想 = 极其灵活 + 100% SEO 友好)。

到目前为止我得到的结果是:

在 .htaccess 的帮助下,任意数量的变量都作为数组传递给 php。 意思是,这个:

www.example.com/somepage/subpage/some-parameters-too

会给我一个包含3个字符串

“somepage”的 数组 ‘子页面’ 'some-parameters-too'

现在...这很好用,但如果我在这里:

www.example.com/somepage/

并单击菜单中的“主页”,它实际上会调用一个不存在的页面

www.example .com/somepage/home

现在...

我知道如果我的锚标记而不是“home”包含“http://www.example.com/home”, 这会起作用,但我读过(在网站上的某个地方)它既无效又 不安全(并且被许多主机禁用 - 我知道它在我的本地主机上默认被禁用)

那么 - 如何做到这一点?

我看到 stackoverflow 上的链接显示为绝对网址,我在哪里犯了错误?

谢谢。

I'm bashing my head for weeks trying to find the ideal way to do php navigation.

(Ideal = extremely flexible + 100% SEO friendly).

Where I got thus far:

With help of .htaccess, any number of variables is passed to php as an array.
Meaning, this:

www.example.com/somepage/subpage/some-parameters-too

will give me an array with 3 strings

'somepage'
'subpage'
'some-parameters-too'

Now...this works nicely, but if I'm here:

www.example.com/somepage/

and click 'home' in my menu, it practically calls a non-existing page

www.example.com/somepage/home

Now...

I know that if my anchor tag instead of "home" contained "http://www.example.com/home",
that would work, but I've read (here on site somewhere) that it's both ineffective and
insecure (and disabled by many hosts - i know it's disabled by default on my localhost)

So - how to do this?

I see links on stackoverflow showing as absolute urls, where am I making a mistake?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤君无依 2024-10-16 20:33:17

我认为您可以使用 元素来指定必须从哪个 url 开始相对路径。
http://www.w3schools.com/tags/tag_base.asp

I think you can use <base> element to specify from which url must start relative paths.
http://www.w3schools.com/tags/tag_base.asp

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文