Skip to content

Instantly share code, notes, and snippets.

Created April 7, 2015 20:23
What would you like to do?
WordPress htaccess
RewriteRule ^rss.xml$ /index.php?feed=rss2&cat=-847 [L,R]
RewriteRule ^snippets.xml$ /index.php?feed=rss2&cat=847 [L,R]
RewriteRule ^feed/$ /rss.xml [L,R]
RewriteRule ^category/(.*)\.html$ /category/$1/ [L,R]
Copy link

  • change 847 with the category ID that you status posts get assigned to
  • Your code caused a redirect loop for me, the following code did what I wanted (I included a bit more context)
  • The rules depend on the permalink structure (mine currently is: /%year%/%monthnum%/%postname%)
  • It seems to work best when the rules are places before the BEGIN/END Wordpress comment blocks as these are replaced when the permalinks structure changes, as below:
# BEGIN snippets
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^rss\.xml$ "/feed?cat=-847"[L,R]
RewriteRule ^snippets\.xml$ "/feed?cat=847"[L,R]
RewriteCond %{Query_STRING} ^$
RewriteRule ^feed$ "/rss.xml" [L,R]
# END snippets

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

Copy link

manton commented Jun 25, 2015

@svandragt Thanks for including your notes and a more complete example!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment