Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to access domain.com/api/(.*) instead of domain.com/public/api/(.*)

Directory structure:



RewriteEngine on
SetEnv APPLICATION_ENV    production

RewriteRule ^$ /public/ [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_URI} !^/api/
RewriteRule ^(.*)$ /public/$1 [L]


RewriteEngine on
SetEnv APPLICATION_ENV    production

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]

I tried different combinations and I came to this simplest one. I tried Alias, put the api folder on root directory, etc.

To mention that the index.html from public folder is loaded first at domain.com, public folder is document root.

share|improve this question
Try to raise your mod_rewrite Loglevel. This is achieved differently for Apache 2.2 and 2.4: httpd.apache.org/docs/2.4/mod/mod_rewrite.html#logging –  weeheavy Feb 13 '13 at 9:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.