2016-01-12 26 views
2

我想重定向開頭的所有網頁:重定向頁面及其子元素的單頁

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 
+0

除了'https:// www.portal-gestao.com/forum'外,您的第一條規則應該是有效的。你的第二條規則應該可以工作,但不會像你期望的那樣行事。 ** 1)**確保'mod_rewrite'已啓用。 ** 2)**確保允許htaccess(apache配置)。 ** 3)**如果您的htaccess中有其他規則,請用整個文件更新您的問題 –

+0

謝謝,是的,我已啓用mod_rewrite和其他自定義重定向。我會更新這個問題。 –

+0

看看你的htaccess。你能告訴我,如果其他規則正在工作?這只是一個不工作或其他人嗎? –

回答

0

使用此:

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

應該是當然你的根htaccess的。

+0

謝謝,看看我上面的編輯。我也試過這個,但它不起作用。 –