Apache 将页面及其子元素重定向到单个页面

Apache 将页面及其子元素重定向到单个页面,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我想重定向以以下内容开头的所有页面: https://www.portal-gestao.com/forum * 致: 无论是: https://www.portal-gestao.com/forum 或: 他们都应该指出: https://www.portal-gestao.com/fórum-perguntas-e-respostas.html 这就是我正在尝试的: RewriteRule ^forum/(.*)$ https://www.portal-gestao.com/fórum

我想重定向以以下内容开头的所有页面:

https://www.portal-gestao.com/forum *
致:

无论是:

https://www.portal-gestao.com/forum
或:

他们都应该指出:

https://www.portal-gestao.com/fórum-perguntas-e-respostas.html
这就是我正在尝试的:

RewriteRule ^forum/(.*)$ https://www.portal-gestao.com/fórum-perguntas-e-respostas.html/? [R=301,L]
以及:

编辑

以下是所有其他重定向:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.portal-gestao.com
RewriteRule ^gestao/item/(.*)$ /artigos/$1 [R=301,L]
RewriteRule ^component/k2/(.*)$ /artigos/$1 [R=301,L]
RewriteRule ^component/k2/(.*)$ /artigos/$1 [R=301,L]
RewriteRule ^itemlist/user/(.*)$ /artigos/author/$1 [R=301,L]
RewriteRule ^tag/(.*)$ /artigos/tag/$1 [R=301,L]
RewriteRule ^forum(/|$) /fórum-perguntas-e-respostas.html[R]

##Ver http://stackoverflow.com/questions/33628668/replace-4-digit-in-url-by-text-4-digit Estava com erros 404 (10-11-2015)
RewriteRule ^(\d{4}-.*)$ /item/$1 [R=301,L]

## Redirect para substituir /item por /artigos/ no URL ver: http://stackoverflow.com/questions/33283968/redirect-part-of-url
RewriteEngine On
RewriteRule ^item/(.+)$ /artigos/$1 [R=301,L]

## End - Custom redirects
使用以下命令:

RewriteEngine on
RewriteRule ^forum(/|$) /fórum-perguntas-e-respostas.html[R]

当然,它应该在您的根htaccess中。

除了
https://www.portal-gestao.com/forum
。你的第二条规则也应该有效,但不会像你预期的那样。1) 确保启用了
mod_rewrite
。2) 确保允许htaccess(apache配置)。3) 如果您的htaccess中有其他规则,请使用整个文件更新您的问题谢谢,是的,我已启用mod_rewrite和其他自定义重定向。我将更新问题。查看您的htaccess。你能告诉我其他规则是否有效吗?只有这一条不起作用还是其他的也起作用?是的,除了这一条,所有其他规则都起作用。你正在测试的url是什么?当你说“不工作”时,你的意思是什么都没发生?我不知道这是否是打字错误,但您需要在您的规则和
[R]
标记之间添加一个空格。谢谢,请参见上面的编辑。我也试过了,但不起作用。
RewriteRule ^forum/(.*)$ https://www.portal-gestao.com/fórum-perguntas-e-respostas.html/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.portal-gestao.com
RewriteRule ^gestao/item/(.*)$ /artigos/$1 [R=301,L]
RewriteRule ^component/k2/(.*)$ /artigos/$1 [R=301,L]
RewriteRule ^component/k2/(.*)$ /artigos/$1 [R=301,L]
RewriteRule ^itemlist/user/(.*)$ /artigos/author/$1 [R=301,L]
RewriteRule ^tag/(.*)$ /artigos/tag/$1 [R=301,L]
RewriteRule ^forum(/|$) /fórum-perguntas-e-respostas.html[R]

##Ver http://stackoverflow.com/questions/33628668/replace-4-digit-in-url-by-text-4-digit Estava com erros 404 (10-11-2015)
RewriteRule ^(\d{4}-.*)$ /item/$1 [R=301,L]

## Redirect para substituir /item por /artigos/ no URL ver: http://stackoverflow.com/questions/33283968/redirect-part-of-url
RewriteEngine On
RewriteRule ^item/(.+)$ /artigos/$1 [R=301,L]

## End - Custom redirects
RewriteEngine on
RewriteRule ^forum(/|$) /fórum-perguntas-e-respostas.html[R]