views:

141

answers:

1

Hello,

I recently found an article online that told me about this:

RewriteRule ^mock-up/([^/]+)/([^/]+) /mock-up/index.php?page=$1&section=$2 [NC]

Only thing that is driving me crazy right now is if I want to be able to have the 2nd directory or not. Like:

RewriteRule ^mock-up/([^/]+)/([^/]+) /mock-up/index.php?page=$1&section=$2 [NC]
RewriteRule ^mock-up/([^/]+) /mock-up/index.php?page=$1 [NC]

But that's breaking apache... so what to do? Please help, I need to seo for my client and I would prefer not to have to make individual files for this.

+1  A: 

The problem is that mock-up/index.php is also matched by mock-up/([^/]+). So you need to exclude the target, either directly:

RewriteRule ^mock-up/index\.php$ - [L]

Or indirectly:

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

So try this:

RewriteRule ^mock-up/index\.php$ - [L]
RewriteRule ^mock-up/([^/]+)/([^/]+)$ /mock-up/index.php?page=$1&section=$2 [NC]
RewriteRule ^mock-up/([^/]+)$ /mock-up/index.php?page=$1 [NC]
Gumbo
thank you for the quick reply, i rarely ever touch .htaccess unless i need to, but i noticed wordpress implements this clever strategy.that works, but other files in that 'mock-up' directory are no longer showing up, so do have any suggestions?i appreciate your help!
Lucas
the indirect method corrected this issue. thanks!!!
Lucas
@Lucas: If my answer answered your question, please mark it as accepted answer.
Gumbo