黑帽联盟

 找回密码
 会员注册
查看: 1698|回复: 0
打印 上一主题 下一主题

[建站文章] WordPress伪静态设置 (win主机伪静态规则 )

[复制链接]

852

主题

38

听众

3173

积分

白金VIP

Rank: 8Rank: 8

  • TA的每日心情
    开心
    2024-3-7 12:52
  • 签到天数: 1538 天

    [LV.Master]伴坛终老

    WordPress伪静态设置规则,301重定向设置方法(win主机)

    本站空间为win主机,关于伪静态和301重定向问题,研究了好长时间终于好了。现在共享给win主机的会员。

    win主机伪静态和301重定向都需要用到httpd.ini文件,上传到网站根目录。
    (有httpd.ini文件的修改,没有的直接新建)
    先上完整代码:
    1. [ISAPI_Rewrite]
    2. # 3600 = 1 hour
    3. CacheClockRate 3600
    4. RepeatLimit 32
    5. RewriteCond Host: ^yhaow.com$
    6. RewriteRule (.*) http://blog.yhaow.com$1 [R,I]
    7. # Protect httpd.ini and httpd.parse.errors files
    8. # from accessing through HTTP
    9. # wordpress
    10. # For tag
    11. RewriteRule /tag/(.*)/page/(d+)$ /index.php?tag=$1&paged=$2
    12. RewriteRule /tag/(.+)$ /index.php?tag=$1
    13. # For category
    14. RewriteRule /category/(.*)/page/(d+)$ /index.php?category_name=$1&paged=$2
    15. RewriteRule /category/(.*) /index.php?category_name=$1
    16. # For sitemapxml
    17. RewriteRule /sitemap.xml /sitemap.xml [L]
    18. RewriteRule /sitemap.html /sitemap.html [L]
    19. RewriteRule /sitemap_baidu.xml /sitemap_baidu.xml [L]
    20. RewriteRule /favicon.ico /favicon.ico [L]
    21. # For file-based wordpress content (i.e. theme), admin, etc.
    22. RewriteRule /wp-(.*) /wp-$1 [L]
    23. # For normal wordpress content, via index.php
    24. RewriteRule ^/$ /index.php [L]
    25. RewriteRule /(.*) /index.php/$1 [L]
    复制代码
    WP伪静态说明:
    需要在wordpress后台 设置→固定连接→自定义为 /%category%/%postname%.html
    [toggle title=”固定连接参数”]%year%:基于文章发布的年份;
    %monthnum%:基于文章发布的月份;
    %day%:基于文章发布当日;
    %hour%:基于文章发布小时数;
    %minute%:基于文章发布分钟数;
    %second%:基于文章发布秒数;
    %postname%:基于文章的postname,其值为撰写时指定的缩略名,不指定缩略名时是文章标题;
    %post_id%:基于文章post_id;
    %category%:基于文章分类,子分类会处理成“分类/子分类”这种形式;
    %author%:基于文章作者名。[/toggle]
    [toggle title=”网上常见的几种设置方法”]/%year%/%monthnum%/%day%/%postname%/
    /%year%/%monthnum%/%postname%/
    /%year%/%monthnum%/%day%/%postname%.html
    /%year%/%monthnum%/%postname%.html
    /%category%/%postname%.html
    /%post_id%.html
    本站采用/%post_id%.html格式,个人觉得简单[/toggle]

    301重定向说明:
    以本站为例:需要把cnblackhat.com重定向到www.cnblackhat.com代码如下:
    RewriteCond Host: ^cnblackhat.com$ RewriteRule (.*) http://www.cnblackhat.com$1 [R,I] 以上代码,请根据你的网站自行修改。

    帖子永久地址: 

    黑帽联盟 - 论坛版权1、本主题所有言论和图片纯属会员个人意见,与本论坛立场无关
    2、本站所有主题由该帖子作者发表,该帖子作者与黑帽联盟享有帖子相关版权
    3、其他单位或个人使用、转载或引用本文时必须同时征得该帖子作者和黑帽联盟的同意
    4、帖子作者须承担一切因本文发表而直接或间接导致的民事或刑事法律责任
    5、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
    6、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
    7、黑帽联盟管理员和版主有权不事先通知发贴者而删除本文

    勿忘初心,方得始终!
    您需要登录后才可以回帖 登录 | 会员注册

    发布主题 !fastreply! 收藏帖子 返回列表 搜索
    回顶部