301重定向不工作 - 任何人都知道为什么吗? [英] 301 Redirects not working - Anyone know why?

查看:109
本文介绍了301重定向不工作 - 任何人都知道为什么吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能帮助?出于某种原因,301重定向不工作....重写conditons通过删除扩展格式化我的网址,所以不知道我是否需要从301语句删除扩展与否。

 选项+了FollowSymLinks
RewriteEngine叙述上
的RewriteCond%{HTTP_HOST}!^ WWW \ .beingchildren \ .ORG $ [NC]
重写规则^(。*)http://www.beingchildren.org/$1 [L,R = 301]


的RewriteCond%{THE_REQUEST} \ S / +(?:指数)?(。*?)\。HTM [\ S?] [NC]
重写规则^ /%1 [R = 301,L,NE]
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{THE_REQUEST} \ S(。+?)/ +?\ S]
重写规则^%1 [R = 301,L]
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{DOCUMENT_ROOT} / $ 1.htm -f
重写规则^(。+?)/?$ /$1.htm [L]


ErrorDocument的404 /404.php

重定向301 /Blog/2012-12-25-Christmas-$p$psents.htm http://www.beingchildren.org/Children-Charity-Blog
重定向301 /Blog/2013-03-29-Mixed-Slum-Photos.htm http://www.beingchildren.org/Children-Charity-Blog
重定向301 /Blog/2013-05-14-Monthly-Slum-Visits-1.htm http://www.beingchildren.org/Children-Charity-Blog
重定向301 /Blog/2013-06-12-Panjim-Monsoon.htm http://www.beingchildren.org/Children-Charity-Blog
重定向301 /Blog/2013-06-15-Margao-Charity-Donations-1.htm http://www.beingchildren.org/Children-Charity-Blog
重定向301 /Blog/2013-09-08-Margao-Ganesh-Celebrations.htm http://www.beingchildren.org/Children-Charity-Blog
重定向301 /Blog/2013-09-08-Margao-Ganesh-Holidays.htm http://www.beingchildren.org/Children-Charity-Blog
重定向301 /Charity.htm http://www.beingchildren.org
重定向301 /Children-Charity-Pictures.htm http://www.beingchildren.org/Children-Charity-Blog
 

解决方案

这是因为2个问题:

  • 301规则是在后底部热媒被删除
  • 混合 mod_alias中的mod_rewrite 规则

试试这个code来代替:

 选项+了FollowSymLinks
RewriteEngine叙述上
的RewriteCond%{HTTP_HOST}!^ WWW \ .beingchildren \ .ORG $ [NC]
重写规则^(。*)http://www.beingchildren.org/$1 [L,R = 301]

重写规则^博客/ 2012年12月25日,Christmas- presents \的.htm $ http://www.beingchildren.org/Children-Charity-Blog [L,R = 301,NC]
重写规则^博客/ 2013年3月29日,混合贫民窟照片\的.htm $ http://www.beingchildren.org/Children-Charity-Blog [L,R = 301,NC]

的RewriteCond%{THE_REQUEST} \ S / +(?:指数)?(。*?)\。HTM [\ S?] [NC]
重写规则^ /%1 [R = 301,L,NE]
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{THE_REQUEST} \ S(。+?)/ +?\ S]
重写规则^%1 [R = 301,L]
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{DOCUMENT_ROOT} / $ 1.htm -f
重写规则^(。+?)/?$ /$1.htm [L]
 

PS:我已经转换只能顶2的301规则。一旦这些工作,你同样可以转换休息。

Can someone help? For some reason the 301 redirects are not working.... The rewrite conditons format my urls by removing the extensions, so not sure if I need to remove the extensions from the 301 statements or not.

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.beingchildren\.org$ [NC]
RewriteRule ^(.*) http://www.beingchildren.org/$1 [L,R=301]


RewriteCond %{THE_REQUEST} \s/+(?:index)?(.*?)\.htm[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.htm -f
RewriteRule ^(.+?)/?$ /$1.htm [L]


errordocument 404 /404.php

Redirect 301 /Blog/2012-12-25-Christmas-Presents.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Blog/2013-03-29-Mixed-Slum-Photos.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Blog/2013-05-14-Monthly-Slum-Visits-1.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Blog/2013-06-12-Panjim-Monsoon.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Blog/2013-06-15-Margao-Charity-Donations-1.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Blog/2013-09-08-Margao-Ganesh-Celebrations.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Blog/2013-09-08-Margao-Ganesh-Holidays.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Charity.htm http://www.beingchildren.org
Redirect 301 /Children-Charity-Pictures.htm http://www.beingchildren.org/Children-Charity-Blog

解决方案

It is because of 2 issues:

  • 301 rules are at the bottom after .htm is removed
  • mixing of mod_alias and mod_rewrite rules

Try this code instead:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.beingchildren\.org$ [NC]
RewriteRule ^(.*) http://www.beingchildren.org/$1 [L,R=301]

RewriteRule ^Blog/2012-12-25-Christmas-Presents\.htm$ http://www.beingchildren.org/Children-Charity-Blog [L,R=301,NC]
RewriteRule ^Blog/2013-03-29-Mixed-Slum-Photos\.htm$ http://www.beingchildren.org/Children-Charity-Blog [L,R=301,NC]

RewriteCond %{THE_REQUEST} \s/+(?:index)?(.*?)\.htm[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.htm -f
RewriteRule ^(.+?)/?$ /$1.htm [L]

PS: I have converted only top 2 of your 301 rules. Once those are working you can similarly convert rest.

这篇关于301重定向不工作 - 任何人都知道为什么吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆