html - htaccess 重写规则。我不想全部重写 - 如何排除某些页面?

标签 html wordpress .htaccess mod-rewrite

我的htaccess如下:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^moreinfo/(.*)$ http://www.kgstiles.com/moreinfo$1 [R=301]
    RewriteRule ^healthsolutions/(.*)$ http://www.kgstiles.com/healthsolutions$1 [R=301]
    RewriteRule ^(.*)\.html$ $1/ [R=301]
    RewriteRule ^(.*)\.htm$ $1/ [R=301]
</IfModule>

我现在使用的是 wordpress 而不是直接的 html 编码。上面的重写规则用于转发根目录以及/moreinfo/和/healthsolutions/目录中的所有旧 .html 和 .htm 页面。不幸的是,他们还从 wordpress 页面中删除了 .htm 和 .html(我认为它们最初都以 php 结尾)。现在我看到了一些基本功能,比如在 wordpress 的可视化编辑器中打开图像编辑器以 .html 结尾(使用它们会产生 404 错误)。

所以问题是:有什么方法可以将我的重写规则限制在某些目录中,这样 Wordpress 功能就不会受到阻碍吗?

感谢任何帮助!

最佳答案

你可以尝试这样的事情:

重写引擎开启

# assuming wordpress is installed in blog directory
RewriteRule ^blog(/.*|)$ - [L] # don't take any action

RewriteRule ^moreinfo/(.*)$ http://www.kgstiles.com/moreinfo$1 [R=301,L]
RewriteRule ^healthsolutions/(.*)$ http://www.kgstiles.com/healthsolutions$1 [R=301,L]
RewriteRule ^(.*)\.html$ $1/ [R=301,L]
RewriteRule ^(.*)\.htm$ $1/ [R=301,L]

关于html - htaccess 重写规则。我不想全部重写 - 如何排除某些页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13828564/

相关文章:

wordpress - .htaccess 和 WordPress : Exclude folder from RewriteRule

mysql - WordPress - 数据库 FIND_IN_SET

wordpress - wp 未定义函数 add_settings_section

linux - DDOS 模组重写 IP 请求

php - 将动态网址转换为静态网址

javascript - 更改图像预览并获取 img 标签的值

javascript - 当用户在不同的电台/专辑上点击播放时,我想改变封面图片

javascript - 带有本地存储的便利贴

HTML - 使输入字段可选择但不可更改

php - 在 htaccess 中重定向