pdaniel93
pdaniel93

Reputation: 13

htaccess mod_rewrite cakephp folder inside rule

One small question for the one that know the syntax of mod_rewrite.

I have a cakephp app on a domain. And the .htaccess file there is pretty straightforward:

RewriteEngine on
RewriteRule    ^$ app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1 [L]

But I would like to add a directory, let's call it "test_dir" so that when in the browser I type domain.com/test_dir/ it will go to that test_dir directory and not app/webroot/

I tried this and succeeded only in a way, by typing only

RewriteRule    ^test_dir.$ test_dir/ [L]

But like this, as it is normal, the other rule isn't no more. So is there an "if" statement or something like that?

Thanks, Daniel

Upvotes: 1

Views: 119

Answers (1)

ADmad
ADmad

Reputation: 8100

   RewriteRule    ^$ app/webroot/    [L]

   RewriteCond    %{REQUEST_URI} !^/test_dir/.*
   RewriteRule    (.*) app/webroot/$1 [L]

Upvotes: 1

Related Questions