禁止在Wordpress中访问父类别

时间:2013-02-22 13:39:45

标签: wordpress .htaccess parent categories

我们的一个Wordpress中只有一个子类别,只有一个父类别。我们不希望用户可以转到父类别,因为它是空的和丑陋的。

问题是...谷歌正在索引父类别,此外,您可以直接在浏览器中写入父类别的网址。

我们一直在尝试使用这些简单的句子(等等),但仍然无效

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} /WE-WANT-THIS-OFF!!!!!!/
Rewriterule ^$ http://www.mydomain.com [L,R=301]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

还有其他建议吗?在此先感谢大家:D !!

1 个答案:

答案 0 :(得分:1)

您应该将重写规则放在RewriteBase指令下面,因为规则在匹配时使用此基数。您也不需要重写条件,因为您只是匹配模式。唯一的RewriteRule就足够了。

尝试这样的事情:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Don't do anything if index.php
RewriteRule ^index\.php$ - [L]

# Redirect category
Rewriterule ^category/my-parent-category/?$ http://{{SERVER_NAME}} [R=301,L]

# Pass all other requests to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>
# END WordPress
相关问题