简体   繁体   English

.htaccess Wordpress类别-重定向到主页

[英].htaccess Wordpress Category - redirecting to homepage

My .htaccess file 我的.htaccess文件

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

Im getting redirect to HomePage but only on one wordPress category. 我正在重定向到主页,但仅在一个wordPress类别上。 Problematic category is airlines. 问题类别是航空公司。 url/airlines/test/ 网址/航空公司/测试/

Had this line previously in .htaccess, but deleted. 以前在.htaccess中具有此行,但已删除。

#RewriteRule ^airlines/(.*)/(.*).png$ ./upload-router.php?folder=$1&airline=$2 [L ] #RewriteRule ^airlines/(.*)/(.*).png$ ./upload-router.php?folder=$1&airline=$2 [L ]

Also rebuilder permaLinks. 也是重建器的永久链接。

I can fix this bug by changing /%category%/%postname%/ to /%category%xxx/%postname%/ , but ofcourse I need how it was original. 我可以通过将/%category%/%postname%/更改为/%category%xxx /%postname%/来修复此错误 ,但是当然我需要它的原始方式。

I can also FIX it by renaming category to airlines2 我也可以通过将类别重命名为Airlines2来对其进行修复

It might be simpler to use wp_redirect() to redirect the category. 使用wp_redirect()重定向类别可能更简单。

function redirect_airlines_category() {
    if (is_category( 'airlines' ) && !is_single()) {
        $new_url = "http://frontpage";
        wp_redirect($new_url, 301);
        exit;
    }
}
add_action('template_redirect', 'redirect_airlines_category');

Place this in your functions.php, change frontpage to the url of your front page, and queries to the category page should get redirected. 将此放置在您的functions.php中,将首页更改为首页的url,并应重定向到类别页面的查询。

在更新.htaccess文件后尝试更新永久链接设置,它可以解决您的问题。

Fixed. 固定。 Large project and somehow there was conflict between slugs. 大型项目,以及between之间存在冲突。 Sorry for inconvenience. 对造成的不便表示歉意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM