Profil de 显华大天使的呼吸PhotosBlogListesPlus Outils Aide

Blog


19/05/2009

htaccess设置中Redirect permanent和RedirectMatch的区别

简单来说吧他们最大的区别就是一个允许使用正则一个不允许使用,其它的他们完全相同都是用来设置网址跳转的。

Redirect permanent 不允许使用正则

RedirectMatch 可以使用正则

举一个真实的例子,我因为网站数据结构的修改以及以前目录设置的问题,网站d1999特别容易出现重新生成的文件名和以前的文件名不相同的情况,而问题就出现在生成网页名的时候使用了日期,而因为时区的设置问题,日期有时候会不同,所以造成生成的页面也不同,当然现在已经知道问题在那里了,采用了新的日期生成方式,可以当时是不知道的,已经生成的页面如何处理呢?就可以用.htaccess对页面进行301跳转。

例子:

要把

http://www.d1999.com/BTxiazai/200805/07-7028.html
去掉最后个/后边到-的内容 变成
http://www.d1999.com/BTxiazai/200805/7028.html

怎么处理呢?最好的办法用正则对访问页面进行匹配,然后重新转到正确的网址,正则的写法如下。

^/([^/]+)/([^/]+)/(?:.*-)(.*) http://www.d1999.com/$1/$2/$3

在网上搜索如何进行网址跳转的设置都给出Redirect permanent于是写出如下代码

Redirect permanent ^/([^/]+)/([^/]+)/(?:.*-)(.*) http://www.d1999.com/$1/$2/$3

结果无效,找服务器提供商解决业务人员不精此道无法解决,于是上网搜索。

终于在一个老外的文章里找到答案要使用RedirectMatch,写成

RedirectMatch ^/([^/]+)/([^/]+)/(?:.*-)(.*) http://www.d1999.com/$1/$2/$3

的格式才行,于是马上实践果然成功。

最后说一下301定向对于搜索引擎优化是很有帮助的,特别是在大量重复文章的情况下,用这个方法可以避免网页被认为是垃圾站而降权。

之前我就是不知道这个规则d1999被降权的很严重,不过有个网站进行SEO的研究也是很值得又学到了新的东东,如果你也学到了,别忘了回复哦。

 

最后提供一些学习资料:

Commentaires (3)

Veuillez patienter...
Le commentaire entré est trop long. Raccourcissez-le.
Vous n'avez rien entré. Réessayez.
Il est actuellement impossible d'ajouter votre commentaire. Réessayez plus tard.
Pour ajouter un commentaire, tu dois avoir l'autorisation de tes parents. Demander l'autorisation
Tes parents ont désactivé les commentaires.
Il est actuellement impossible de supprimer votre commentaire. Réessayez plus tard.
Vous avez dépassé le nombre maximal de commentaires qu'il est possible d'envoyer le même jour. Réessayez dans 24 heures.
Votre compte a pu laisser les commentaires désactivés parce que nos systèmes indiquent que vous risquez d'arroser d'autres utilisateurs de messages. Si vous pensez que votre compte a été désactivé par erreur, contactez l'assistance en ligne de Windows Live.
Effectuez la vérification de sécurité ci-dessous pour finaliser l'envoi de votre commentaire.
Les caractères entrés pour la vérification de sécurité doivent correspondre à ceux de l'image ou du fichier audio.

Pour ajouter un commentaire, connectez-vous avec votre identifiant Windows Live ID (si vous utilisez Messenger ou Xbox LIVE, vous avez un identifiant Windows Live ID). Connectez-vous


Vous n'avez pas d'identifiant Windows Live ID ? Inscrivez-vous

Aucun noma écrit :
http://reod.setaco.jp/
http://ewoe.setaco.jp/
http://zduoe.setaco.jp/
http://roeud.setaco.jp/
http://edfea.setaco.jp/
http://zoedd.setaco.jp/
http://bade.setaco.jp/
http://bingyi.jugem.jp/
http://werd.jugem.jp/
http://rfef.jugem.jp/
http://baedf.jugem.jp/
http://bdfae.jugem.jp/
http://gadfa.jugem.jp/
http://dsre.jugem.jp/
http://bingyi.hamazo.tv/
http://dgdzd.hamazo.tv/
http://terd.hamazo.tv/
http://defaf.hamazo.tv/
http://bsfga.hamazo.tv/
http://fcgfgb.hamazo.tv/
http://bingyi.eshizuoka.jp/
http://rovr.eshizuoka.jp/
http://dozed.eshizuoka.jp/
http://zodenf.eshizuoka.jp/
http://bedaoe.eshizuoka.jp/
http://rewdg.eshizuoka.jp/
http://hboak.eshizuoka.jp/
http://bingyi.saitamania.net/
http://bingyi.da-te.jp/
http://xfgb.da-te.jp/
http://yncgg.da-te.jp/
http://nxfvv.da-te.jp/
http://fgaf.da-te.jp/
http://jhgdg.da-te.jp/
http://xcgdg.da-te.jp/
http://nxgfr.da-te.jp/
http://bingyi.nassy.jp/
http://rwdf.nassy.jp/
http://bingyi.gnomz.com/
http://dedeo.da-te.jp/
http://bzzdd.da-te.jp/
http://zdfddf.da-te.jp/
http://xdrfe.da-te.jp/
http://dfdfz.da-te.jp/
http://bingyi.radilog.net/
http://zoef.mie1.net/
http://zeod.mie1.net/
http://todue.mie1.net/
http://zdtdt.mie1.net/
http://tedte.mie1.net/
http://teetad.mie1.net/
http://sedae.mie1.net/
http://taide.mie1.net/
http://mideo.mie1.net/
http://vode.mie1.net/
http://ztde.mie1.net/
http://toye.mie1.net/
http://tvad.eshizuoka.jp/
http://tdbd.eshizuoka.jp/
http://batde.eshizuoka.jp/
http://eewrd.eshizuoka.jp/
http://ywde.eshizuoka.jp/
http://bvzd.eshizuoka.jp/
http://bvzde.eshizuoka.jp/
http://uyoe.eshizuoka.jp/
http://nvnv.eshizuoka.jp/
http://zeod.eshizuoka.jp/
14 Juil.
Aucun noma écrit :
http://tw.myblog.yahoo.com/zhdodfe
http://tw.myblog.yahoo.com/zpdoe
http://tw.myblog.yahoo.com/hhkgd
http://tw.myblog.yahoo.com/yyyoozd
http://www.wretch.cc/blog/apqidu
http://www.wretch.cc/blog/qiekeh
http://www.wretch.cc/blog/qideo
http://www.wretch.cc/blog/peidosd
http://www.wretch.cc/blog/iieod
http://www.wretch.cc/blog/rwoed
http://www.wretch.cc/blog/bhfsf
http://www.wretch.cc/blog/bdfddf
http://www.wretch.cc/blog/ooiieed
http://www.wretch.cc/blog/trewqhfg
http://www.wretch.cc/blog/iooie
http://www.wretch.cc/blog/pozireq
http://www.wretch.cc/blog/zhdodfe
http://www.wretch.cc/blog/zpdoe
http://www.wretch.cc/blog/hhkgd
http://www.wretch.cc/blog/yyyoozd
http://blog.udn.com/bingyilg
http://blog.udn.com/aoeid/
http://blog.udn.com/oouu36
http://blog.udn.com/ooii
http://blog.udn.com/yyoo36
http://blog.udn.com/ppoo36
http://blog.udn.com/mini36
http://blog.udn.com/nvnv
http://blog.udn.com/hjjh
http://blog.udn.com/gghj
http://yu36.blog.ithome.com.tw/
http://yt36.blog.ithome.com.tw/
http://bb36.blog.ithome.com.tw/
http://re36.blog.ithome.com.tw/
http://qi36.blog.ithome.com.tw/
http://pp36.blog.ithome.com.tw/
http://blog.xuite.net/oouu36/blog/
http://blog.eztravel.com.tw/you36
http://blog.mook.com.tw/tr36
http://alive.tom.com/oruy
http://alive.tom.com/ubol
http://alive.tom.com/wsdf
http://alive.tom.com/vdal
http://alive.tom.com/vade
http://alive.tom.com/dzed
http://alive.tom.com/oerd
http://alive.tom.com/yrtd
http://alive.tom.com/uyrf
http://alive.tom.com/tede
http://blog.eztravel.com.tw/er36
http://blog.eztravel.com.tw/tede
http://blog.eztravel.com.tw/gaer36
http://blog.tyc.edu.tw/b/erd
http://blog.tyc.edu.tw/b/yyoo
http://blog.tyc.edu.tw/b/oiu
http://blog.tyc.edu.tw/b/you
http://blog.tyc.edu.tw/b/zdo
http://blog.tyc.edu.tw/b/mnb
http://blog.tyc.edu.tw/b/xcv
http://blog.tyc.edu.tw/b/bvc
http://blog.tyc.edu.tw/b/bnv
http://redr36.wordpress.com/
http://roeu.livejournal.com/
http://bncn.livejournal.com/
http://teded.livejournal.com/
http://eoud.livejournal.com/
http://yourer.livejournal.com/
http://redre.livejournal.com/
http://drere.livejournal.com/
http://www.fuel.tv/bingyi/blogs
http://www.fuel.tv/reod/blogs
http://www.fuel.tv/yyoo/blogs
http://www.fuel.tv/doed/blogs
http://www.fuel.tv/youd/blogs
http://www.fuel.tv/beod/blogs
http://yyoo.setaco.jp/
http://youde.setaco.jp/
14 Juil.
14 Juil.

Rétroliens

L'URL de rétrolien de ce billet est :
http://game60.spaces.live.com/blog/cns!F6595C813506A9DA!2745.trak
Blogs Web qui font référence à ce billet
  • Aucune