我一直试图解决这个问题几天了。 我的根文件夹是https://www.example.com,我有很多文章,但在不同的文件夹和子文件夹中,以便更好地组织。
问题在于我希望链接看起来更好而不是:
> https://www.example.com/reviews/review_1/index.html
/review_2/index.html
/review_3/index.html
或
https://www.example.com/articles/blog/content_1/index.html
/content_2/index.html
/content_3/index.html
但相反,我希望所有文件夹都在"评论和文章"看起来像root / dirs:
https://www.example.com/review_1/index.html
https://www.example.com/content_1/index.html
...所以可以以某种方式排除../reviews/
或../articles/blog/
文件夹,但是要具有相同的目录结构,也不要有重复的内容,索引或重复的DIR?
编辑/我找到了解决方案:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteRule ^review_1/(.*) reviews/review_1/$1
此代码将从文件夹reviews/review_1/
重定向到root上的未发布文件夹review_1
,并将所有内容从reviews/review_1/
复制到review_1
。
答案 0 :(得分:0)
只需创建一个关联箭头,指定url和它们在引擎盖下的含义之间的映射,例如我在php中使用这样的 -
$route = array(
array(
'url' => 'review_1/index.html',
'map_to' => '/articles/blog/reviews/index.html'
),
array(
)
);
或更好的版本,如实现简单路由 -
$route = array(
array(
'url' => '/review/',
'controller' => 'controller_class',
'action' => 'model_class'
),
array(
)
);
更好地继续第二个过程.. 做一些自己实现路由或使用基本框架的研究。 希望它有所帮助。