Wordpress链接到迁移后不起作用的帖子

时间:2016-01-08 07:38:43

标签: wordpress .htaccess mod-rewrite permalinks broken-links

我在访问我的博文时遇到问题。自从我迁移到新服务器后,出现以下问题。

首先,页面和帖子的链接都不起作用。但不知何故,我修复了页面,现在它开始工作了。但是帖子的链接尚未开始。

每当我点击帖子时,都会显示错误500.我已经检查了.htaccess文件,并将Settings > Permalink恢复为默认值,但仍无效。 Mod rewrite也是active,我可以使用固定链接访问网页链接。

任何人都可以帮助指出问题所在吗?

.htaccess file
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

P.S:抱歉我的语法不好,英语不是我的主要语言

2 个答案:

答案 0 :(得分:0)

更新.htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

配置永久链接:

自定义结构:/%postname%/

请查看:https://codex.wordpress.org/File:permalink-settings.png

答案 1 :(得分:0)

好的,所以在检查出我的wordpress主题single.php文件中指出错误的apache错误日志后,我发现罪魁祸首证明了&#34;相关新闻脚本&#34;注入我的单个php文件。每当我尝试访问博客帖子时,这都会导致整个错误500。

脚本是这样的:

                    <!-- Related News -->
                    <div class="relatedposts hidden-xs hidden-sm">
                    <h3>Artikel Lainnya</h3>
                    <p>&nbsp;</p>
                    <?php
                        $orig_post = $post;
                        global $post;
                        $tags = wp_get_post_tags($post->ID);

                        if ($tags) {
                        $tag_ids = array();
                        foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
                        $args=array(
                        'tag__in' => $tag_ids,
                        'post__not_in' => array($post->ID),
                        'posts_per_page'=>3, // Number of related posts to display.
                        'caller_get_posts'=>1
                        );

                        $my_query = new wp_query( $args );

                        while( $my_query->have_posts() ) {
                        $my_query->the_post();
                        ?>

                        <div class="relatedthumb">
                            <a rel="external" href="<? the_permalink()?>"><?php the_post_thumbnail(array('class' => 'img-responsive img-thumbnail',230,170)); ?><br />
                            <h5><?php the_title(); ?></h5>
                            </a>
                        </div>

                        <? }
                        }
                        $post = $orig_post;
                        wp_reset_query();
                        ?>
                    </div>
                    <!-- Related News-->

我删除了那些行,所有问题都解决了!

感谢您分享您的建议!

相关问题