mod_rewrite has always been one of my weakest areas. I've tried to find a solution to this for a while, and many answers simply link to the mod_rewrite documentation, which isn't helpful to me. I believe my problem is pretty simple, so I'm hoping someone won't mind giving me a freebie this time.
I have some existing mod_rewrite rules for Drupal:
RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Which, of course, work fine; they're stock Drupal rules.
I want to redirect requests for
/snippet/yyyy-MMM-dd/name-of-article
to
/snippets/name-of-article
so I changed the rules to this:
RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^snippet/20[0-9]{2}-[a-z]{3}-[0-9]{2}/(.*)$ snippets/$1 [L,R=301] ### MY NEW RULE RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
My new rule works as expected, and performs the redirect properly. However, it seems to affect CSS and JS requests, evident by the lack of styling and scriptin,g and 404 errors in the error log. If I try to view a CSS or JS file directly, I get the same HTML output as it I'd requested the parent document. So, obviously, my rule is broken.
I don't know why this is so hard -- seems simple.