Rewrite and index file

Hello!

I’m haveing a couple of challanges regarding my htaccess file for my site.

I’m using rewrite rules for SEO purposes like:
RewriteRule ^(.*)/$ index.php?sef_tittel=$1
witch would rewrite www.mysite.com/news/ to www.mysite.com/index.php?sef_tittel=news

The problem is that I have several folders on the server for other purposes, and I don’t want www.mysite.com/newsletters/ to be rewritten, there is a index.php file in that folder, but it gets rewritten.

I’ve put a rewrite rule like this to solve the problem:
RewriteRule ^newsletters/$ newsletters/index.php [L]
RewriteRule ^newsletters$ newsletters/index.php [L]

This works, but I don’t think its a good solution, because I have do alter the htaccess file for each new folder i want this on.

I also have a folder with lots of subfolders www.mysite.com/stuff/ with indexfiles. Is there anyway to stop rewrite rules on this specific folder?

It sounds like what you want is to add a condition (RewriteCond) that says “don’t apply the next rule if the current request is for a real directory”. Lucky for you, such a condition exists


RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)/$ index.php?sef_tittel=$1 [L]

:slight_smile:

Ahhh! Just magic, thanks a lot :slight_smile: