I’m trying to use mod_rewrite to create clean links. I’ve gotten it to take my urls from this:
http://www.example.com/index.php?LTKeywords=long-tail-keyword
to
http://www.example.com/long-tail-keyword/
Which is exactly what I want. The code I used is:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/ index2.php?LTKeywords=$1
One Problem.
It now redirects all of my folders, so anything in my /images/ or /css/ folders will not show up. Is there a way to stop it from rewriting specific folders?
The easiest way is probably a
RewriteCond. You can prefix with!to specify must-not-match:for example.
You may also just want to exclude directories which actually exist:
Finally, you could also put your static content on a different hostname (virtualhost), avoiding your rewrite rules all together.
You could also add some more RewriteRules to match your CSS, etc. and make them not actually change anything (rewrite /css to /css) but specify the L (last) flag, so the other rules wouldn’t run.