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

时间:2016-01-12 12:47:05

标签: apache .htaccess mod-rewrite

我想重定向所有以:

开头的网页
https://www.portal-gestao.com/forum *

要:

https://www.portal-gestao.com/fórum-perguntas-e-respostas.html

无论是否:

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

或者:

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

他们都应该指出:

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]

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

1 个答案:

答案 0 :(得分:0)

使用此:

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

当然,它应该在你的根目录中。