具有多个 GET 变量的 PHP 导航
几周来我一直在绞尽脑汁试图找到进行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您可以使用
元素来指定必须从哪个 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