Skip to content

Instantly share code, notes, and snippets.

@manton
Created April 7, 2015 20:23
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save manton/f8b6f8b391a2f3d9b419 to your computer and use it in GitHub Desktop.
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]
@svandragt
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]
</IfModule>
# 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]
</IfModule>
# END WordPress

@manton
Copy link
Author

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