WordPress博客使用win主机去除index.php的方法

前段时间帮朋友做了个的网站,可因为他用的是,做完后文章页面的访问地址一直带index.php,看了就让人烦啊。
而且首页的广告图进到内页后既然不显示,刚开始以为是主题的问题,本地安装了重新测试,本地一点问题都没有,上传到空间就不显示图片了,于是开始折腾……
首先开始对主题进行查看,看有没有哪里的路径弄错了,折腾了一番,没有发现问题。

后来在后台不小心修改了,发现使用默认的方式可以显示图片广告,于是怀疑是index.php的问题,于是网上搜索了一大推关于“”,可怜,找出来的都是千篇一律,就是让你改404.php页面,试了N次,发现这个办法根本不灵,于是继续查找,终于发觉有人说到了httpd.ini文件,但需要服务器开启,让朋友问了空间商,答曰:有开这个模块。

欣喜中,把以下的代码保存成httpd.ini文件并上传到服务器:
[ISAPI_Rewrite]
# Defend your computer from some worm attacks
#RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# Rules to ensure that normal content gets through
RewriteRule /software-files/(.*) /software-files/$1 [L]
RewriteRule /images/(.*) /images/$1 [L]
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule /wp-(.*) /wp-$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]

后台把固定链接设置成/archives/%post_id%.html形式,发现连首页的图片广告都没有显示了,想着是不是杯具了!
再次查看了一下httpd.ini文件代码,好像有个图像的地址要处理,回想了下图片广告的图片在img文件夹里面,于是在代码里面加上了:
RewriteRule /img/(.*) /img/$1 [L]
刷新,ok,首页图片广告出来了,可内页的依然如此顽固,于是再狠心点,在httpd.ini文件里面再加一句:
RewriteRule /archives/(.*) /archives/$1 [L]
现在httpd.ini文件变成了这样:
[ISAPI_Rewrite]
# Defend your computer from some worm attacks
#RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# Rules to ensure that normal content gets through
RewriteRule /software-files/(.*) /software-files/$1 [L]
RewriteRule /images/(.*) /images/$1 [L]
RewriteRule /img/(.*) /img/$1 [L]
RewriteRule /archives/(.*) /archives/$1 [L]
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule /wp-(.*) /wp-$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]

再去后台把固定链接设计成/%post_id%.html,至此,一切大功告成!
累死,欢呼,收工,收钱……

标签:, , , , ,
» 原创文章,欢迎转载,无论转载到哪里,敬请注明来自win-google blogs博客!
» 本文链接地址:http://www.winw2.com/wordpress-blog-using-win-host

» 推荐给您的朋友 / 直接收藏本文

» 把文章转到微博: 转播到腾讯微博



表达强烈不满 ?

63 人表示强烈不满.

  1. 看题目我还以为是删除index.php,原来是url改写。

  2. 学习了,谢谢分享啊 :smile:

  3. wp 还是用linux好,不用那么多的折腾。哈哈

  4. 还没用过win的主机

  5. 空间商后台没这个功能吗?我记得有的空间商后台管理里面可以自己改

  6. 这个的话,用linux 主机可能会好一些~~~

  7. 我也用windows主机,昨天改了固定链接,就出现500错误,郁闷死,搞了好久

  8. 来看看你,我不会高估这个东西

  9. 来关注学习了方法!

  10. 找到方法的那一霎那是多么开心啊!

  11. win主机会这么麻烦啊

  12. 简单的修改,很能折腾啊!

  13. 以前用过wp。似乎也这样弄过

  14. URL重定向好像有的空间商是不安装的

  15. 不用WIN的飘过!!!

  16. liunx一样是用url改写文件的呀,不是么?!

  17. 收钱的感觉爽吧?

  18. 也许以后会用到
    先谢谢了

  19. WIN主机 ,表示不适合WP

  20. 不错哦。自己多亲手去操作会学会很多知识的。。学习了哦,嘿嘿。

  21. linux主机表示不用如此折腾······· :lol:

  22. wp博客用win主机就是个杯具

  23. 主机有没有这个模块怎么查啊,我的空间是我朋友的独立主机。我也不知道有没有这个模块

  24. 成功伪静态也去掉INDEX.PHP,谢谢

  25. 人才哇,能用,木有问题,感谢

无需注册即可评论,期待您一针见血的言论!


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

无觅相关文章插件,快速提升流量