【发布时间】:2013-02-05 16:19:56
【问题描述】:
我在所有文件夹的 index.php 中都有脚本
需要像这样制作漂亮的 url/seo 友好的 url:site.com/folder1/something.html
现在我有这样丑陋的网址:site.com/folder1/index.php?category=something
这部分index.php?category=something 在所有子文件夹中始终相同,我只想将其更改为对 seo 更友好,例如 something.html
再次:找到 index.php?category=1$ 并将其替换为 1$.html
不要碰其他任何东西,只是这部分 url
所以当我访问时:
site.com/another-subfolder/and-one-more-folder-here/index.php?category=something
需要在地址栏中看到这个:
site.com/another-subfolder/and-one-more-folder-here/something.html
希望你明白吗?
我在 root 的 htaccess 中使用 folder1 尝试过这个
RewriteRule ^folder1/(.*).html$ folder1/index.php?category=$1 [L,R=301]
好的,但是我怎样才能使它适用于整个站点的所有子文件夹,如下所示:
site.com/folder145/index.php?category=something
site.com/subfolder/index.php?category=something
site.com/another-subfolder/and-one-more-folder-here/index.php?category=something
会有 1000 个不同名称的子文件夹,因此手动为每个子文件夹创建 RewriteRule 将不起作用
感谢任何帮助
【问题讨论】:
标签: .htaccess