【发布时间】:2017-11-12 14:58:20
【问题描述】:
我这几天一直在尝试解决这个问题。 我的根文件夹是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/ 重定向到根目录上不存在的文件夹 review_1,并将所有内容从 reviews/review_1/ 复制到 review_1。
【问题讨论】:
-
查看重写规则
-
你可以使用
RewriteRule看这里:stackoverflow.com/questions/17293605/…