【发布时间】:2012-05-07 16:23:17
【问题描述】:
请放轻松,因为这对我来说是一个全新的世界。
所以我已经构建了 Little cms 并使用 GET 来控制 url 中的 pageID 或页面永久链接。当仅通过查询字符串传递 1 个变量时,我的脚本工作正常
例如我的htaccess:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ index.php?p=$1
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?p=$1
然后我可以通过在我的索引文件中控制的 id 或永久链接来调用我的页面。我没有弄清楚的一件事是如何在调用子页面时在 url 中包含父永久链接。
另一个例子。如果我调用的页面是父级的子级:
http://site.com/index.php?p=post-title
如果 post-title 是 parent-title 的子项;如何使用网址
http://site.com/parent-title/post-title?
【问题讨论】:
-
你是在说当有人请求
http://site.com/parent-title/post-title时,请求会被重写到你的 index.php 控制器,比如/index.php?p=post-title&parent=parent-title? -
我已经想到了,但我想知道是否有一种方法可以在仅调用后标题时自动包含父标题我确信有一种方法,但 mod_rewrites 几乎都是英文我。但是要回答你的问题。是的,我很喜欢你的建议,但仍然保持干净的网址
-
所以你的意思是:
/index.php?p=parent-title/post-title? -
嗯,这更像是您的第一个建议
/index.php?p=post-title&parent=parent-title,但不仅调用子页面,还自动将父页面包含在 url 中。希望自从 -
当有人请求
http://site.com/parent-title/post-title时,你希望URI是什么样的?
标签: .htaccess friendly-url pretty-urls