I have a blog. The blog is stored under the /blog/ prefix on my website. It has the usual URLs for a blog, so articles have URLs in the format /blog/:year/:month/:day/:title/.
First and foremost, I want to automatically redirect visitors to the www subdomain (in case they leave that off), and internally rewrite the root URL to /blog/, so that the front page of the blog appears on the front page of the site. I have accomplished that with the following set of rewrite rules in my .htaccess file:
RewriteEngine On
# Rewrite monkey-robot.com to www.monkey-robot.com
RewriteCond %{HTTP_HOST} ^monkey-robot\.com$
RewriteRule ^(.*)$ http://www.monkey-robot.com/$1 [R=301,L]
RewriteRule ^$ /blog/ [L]
RewriteRule ^feeds/blog/?$ /feeds/blog/atom.xml [L]
That works fine. The problem is that the front page of the blog now appears at two distinct URLs: / and /blog/. So I'd like to redirect the /blog/ URL to the root URL. Initially I tried to accomplish this with the following set of rewrite rules:
RewriteEngine On
# Rewrite monkey-robot.com to www.monkey-robot.com
RewriteCond %{HTTP_HOST} ^monkey-robot\.com$
RewriteRule ^(.*)$ http://www.monkey-robot.com/$1 [R=301,L]
RewriteRule ^$ /blog/ [L]
RewriteRule ^blog/?$ / [R,L]
RewriteRule ^feeds/blog/?$ /feeds/blog/atom.xml [L]
But that gave me an infinite redirect (maybe because of the preceding rule?). So then I tried this set:
RewriteEngine On
# Rewrite monkey-robot.com to www.monkey-robot.com
RewriteCond %{HTTP_HOST} ^monkey-robot\.com$
RewriteRule ^(.*)$ http://www.monkey-robot.com/$1 [R=301,L]
RewriteRule ^$ /blog/ [L]
RewriteRule ^blog/?$ http://www.monkey-robot.com/ [R,L]
RewriteRule ^feeds/blog/?$ /feeds/blog/atom.xml [L]
But I got a 500 Internal Server Error with the following log message:
Invalid command '[R,L]', perhaps misspelled or defined by a module not included in the server configuration
What gives? I don't think [R,L] is a syntax error.