我发现了许多301 htaccess重定向示例,但我需要一些特定的东西,并且不知道如何构建那个确切的重定向规则...我构建的网站是一个wordpress网站。
示例:
http://www.example.com/article/some-article-01.html
http://www.example.com/article/data-analysis.html
http://www.example.com/article/another-page.html
要重定向到:
http://www.example.com/article/some-article-01/
http://www.example.com/article/data-analysis/
http://www.example.com/article/another-page/
寻找一个适用于wordpress的htaccess规则...
指向相关数据的指针将被接受。似乎找不到合适的搜索查询。示例代码当然要容易得多。
答案 0 :(得分:1)
在DOCUMENT_ROOT/.htaccess
文件中将此规则作为第一条规则插入RewriteBase
行下方
RewriteEngine On
RewriteBase /
RewriteRule ^(article/[^.]+)\.html$ /$1/ [L,NC,R=302]
如果它适用于您,请将302
更改为301
以使其永久重定向。