【问题标题】:404 Error after using Custom URL Structure使用自定义 URL 结构后出现 404 错误
【发布时间】:2013-09-25 10:32:48
【问题描述】:

我已经在 /en 文件夹中安装了 wordpress,并在 / 上设置了 siteurl。我将其转换为多站点网站。它在 topcanadavisa.com 上运行。

我在 function.php 上使用了这段代码来定义新的 post_type(文章):

function codex_custom_init() { 
register_taxonomy('articles-category',array(), array(
    'has-archives' => true,
    'hierarchical' => true, 
    'show_ui' => true,  
    'query_var' => true, 
    'rewrite' => array( 'slug' => 'archive' ),
    ));

register_post_type('articles', array(
    'capability_type' => 'post',    
    'hierarchical' => false,
    'public' => true,               
    'show_ui' => true,                  
    'query_var' => true,        
    'publicly_queryable' => true,   
    'exclude_from_search' => false,
    'supports' => array( 'title', 'editor', 'excerpt', 'trackbacks', 'thumbnail' , 'author', 'custom-fields' ),
    'rewrite' => array( 'slug' => 'articles' ),
    'has-archives' => true,
    'taxonomies' => array( 'articles-category' ,'post_tag') 
));
//flush_rewrite_rules();
} add_action( 'init', 'codex_custom_init' );

wordpress 将这些设置在 .htaccess 上:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) en/$2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ en/$2 [L]
    RewriteRule . index.php [L]

发生的事情是我无法设置自定义永久链接。除“page”类型外的所有帖子类型均返回 404 错误。我该怎么办?

【问题讨论】:

    标签: wordpress .htaccess http-status-code-404 permalinks


    【解决方案1】:

    我遇到过几次,尤其是在 wordpress 找不到自定义帖子类型的情况下。

    我必须做的是转到永久链接设置并更改它们,然后改回我想要的。这会刷新重写规则,然后它就起作用了。

    我不得不手动执行此操作,并且多次遇到问题,每次都以此作为解决方案。

    【讨论】:

    • 没用。我已经这样做了好几次了。即使我被 flush_rewrite_rules() 刷新了,我什至已经从网络管理区域更改了永久链接结构。没用。
    猜你喜欢
    • 2015-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多