Question

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
Was it helpful?

Solution

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]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top