How to redirect main all feed to feedburner except

2019-08-22 04:13发布

问题:

I want to redirect main feed of my blog to feedburner but I don't want to redirect other feeds like: mywordpressblog.ir/feed/?post_type=post or mywordpressblog.ir/feed/?post_type=daily

I have configured the apache .htaccess in this way, but it doesn't work! Any one could help me?

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !FeedBurner [NC]
RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
RewriteCond %{REQUEST_URI} !^/feed/\?post.*$ [NC]
RewriteRule ^(.*)$ http://feeds.khajavi.ir/khajavi  [R=302,NC,L]
</IfModule>


# 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>
# END WordPress

回答1:

You can't match against the query string in the %{REQUEST_URI}, you need to use the %{QUERY_STRING} var:

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !FeedBurner [NC]
RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
RewriteCond %{REQUEST_URI} !^/feed/ [NC]
RewriteCond %{QUERY_STRING} !^post
RewriteRule ^(.*)$ http://feeds.khajavi.ir/khajavi  [R=302,NC,L]