wordpress ---- 相册插件[NextGEN Gallery] 404 错误解决办法
- 2011-12-23 12:59 - fzblog.net
- Views: 171
- Comments: 0
- Wordpress
最近wordpress网站出现404错误, URL类似于:
http://www.xxxxxx.com/gallery/10-really-expensive-christmas-gifts/gallery/image/louis-vuitton-condom
http://www.xxxxxx.com/gallery/awesome-gifts-a-man-should-ask-for/gallery/image/louis-vuitton-condom
http://www.xxxxxx.com/gallery/12-must-play-christmas-songs/gallery/image/louis-vuitton-condom
......
看这地址就知道插件开启了Activate permalinks,

遂用下面地址访问
http://www.xxxxxx.com/gallery/10-really-expensive-christmas-gifts/?pid=122
发现能正常访问,初步判断应该是RewriteRules出问题了;
最后查看[NextGEN Gallery]插件源码,一步步排查,发现这个插件不支持此类型的地址
http://www.xxxxxx.com/gallery/10-really-expensive-christmas-gifts/gallery/image/louis-vuitton-condom
仅仅支持此类型的
http://www.xxxxxx.com/10-really-expensive-christmas-gifts/gallery/image/louis-vuitton-condom
打印出RewriteRules就很明白了:
所以解决方法就是:
在wp-content/plugins/nextgen-gallery/lib/rewrite.php 第263行改成如下代码:
然后在后台做如下操作,问题就可以解决了:
"Settings->Permalink->Save Changes"
http://www.xxxxxx.com/gallery/10-really-expensive-christmas-gifts/gallery/image/louis-vuitton-condom
http://www.xxxxxx.com/gallery/awesome-gifts-a-man-should-ask-for/gallery/image/louis-vuitton-condom
http://www.xxxxxx.com/gallery/12-must-play-christmas-songs/gallery/image/louis-vuitton-condom
......
看这地址就知道插件开启了Activate permalinks,
遂用下面地址访问
http://www.xxxxxx.com/gallery/10-really-expensive-christmas-gifts/?pid=122
发现能正常访问,初步判断应该是RewriteRules出问题了;
最后查看[NextGEN Gallery]插件源码,一步步排查,发现这个插件不支持此类型的地址
http://www.xxxxxx.com/gallery/10-really-expensive-christmas-gifts/gallery/image/louis-vuitton-condom
仅仅支持此类型的
http://www.xxxxxx.com/10-really-expensive-christmas-gifts/gallery/image/louis-vuitton-condom
打印出RewriteRules就很明白了:
代码如下
- [([^/]+)/gallery/page-([0-9]+)/?$] => index.php?name=$matches[1]&nggpage=$matches[2]
- [([^/]+)/gallery/image/([^/]+)/?$] => index.php?name=$matches[1]&pid=$matches[2]
- [([^/]+)/gallery/image/([^/]+)/page-([0-9]+)/?$] => index.php?name=$matches[1]&pid=$matches[2]&nggpage=$matches[3]
- [([^/]+)/gallery/slideshow/?$] => index.php?name=$matches[1]&show=slide
- [([^/]+)/gallery/images/?$] => index.php?name=$matches[1]&show=gallery
- [([^/]+)/gallery/tags/([^/]+)/?$] => index.php?name=$matches[1]&gallerytag=$matches[2]
- [([^/]+)/gallery/tags/([^/]+)/page-([0-9]+)/?$] => index.php?name=$matches[1]&gallerytag=$matches[2]&nggpage=$matches[3]
- [([^/]+)/gallery/([^/]+)/?$] => index.php?name=$matches[1]&album=$matches[2]
- [([^/]+)/gallery/([^/]+)/page-([0-9]+)/?$] => index.php?name=$matches[1]&album=$matches[2]&nggpage=$matches[3]
- [([^/]+)/gallery/([^/]+)/([^/]+)/?$] => index.php?name=$matches[1]&album=$matches[2]&gallery=$matches[3]
- [([^/]+)/gallery/([^/]+)/([^/]+)/slideshow/?$] => index.php?name=$matches[1]&album=$matches[2]&gallery=$matches[3]&show=slide
- [([^/]+)/gallery/([^/]+)/([^/]+)/images/?$] => index.php?name=$matches[1]&album=$matches[2]&gallery=$matches[3]&show=gallery
在wp-content/plugins/nextgen-gallery/lib/rewrite.php 第263行改成如下代码:
代码如下
- $rewrite_rules = array (
- // XML request
- $this->slug . '/slideshow/([0-9]+)/?$' => 'index.php?imagerotator=true&gid=$matches[1]',
- // support gallery page
- $this->slug . '/([^/]+)/([^/]+)/image/([^/]+)/?$' => 'index.php?gallery=$matches[1]&pid=$matches[3]',
- );
然后在后台做如下操作,问题就可以解决了:
"Settings->Permalink->Save Changes"



随便说说