我有一些关于使用 Codeigniter 进行路由的问题。我现在正在做的事情如下:
$route['articles/(:num)'] = 'articles/view/$1'; // $1 will contain an ID
这意味着 example.com/articles/123 将完美运行并加载 ID 为 123 的文章。但我也希望有可能将文章的标题添加到 URL(用于 SEO)。示例:example.com/articles/123/article-title
我想要的与 Stack Overflow 几乎相同:stackoverflow.com/questions/123/the-title
我怎样才能做到这一点?
我也想知道 Stack Overflow 是如何工作的。如果我转到 stackoverflow/questions/111,标题将自动添加到 url。这是用 php redirect() 完成的吗?