Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

how do i move a web app that uses rewrite rules and lives in the root of the web server to a sub-directory?

i have an app running on my apache web server that uses the following rewrite rules in an .htaccess file:

RewriteCond $1 !^(tool|web|files)
RewriteCond %{REQUEST_URI} !((.*)\.(.*))$
RewriteRule ^(.*)$ dispatcher.php?route=/$1 [NC,L]
RewriteRule ^(img|css|js)/(.*) web/$1/$2 [L,QSA]

the app currently lives in the root of the web server. i want to move it to a sub-directory but when i do the app no longer works. i tried adding RewriteBase /newdir but that only makes the main pages work and not the css/img/js directories.

ideally, i'd like to NOT change the existing rules but instead add an additional rule.

share|improve this question

migrated from Oct 8 '11 at 16:51

This question came from our site for professional and enthusiast programmers.

up vote 0 down vote accepted

First, I think the RewriteBase /newdir is right, that would apply your rules in the new directory, the rule works fine.

Second, you may need to remove the caret (^) character from the last rule, something like this should work.

RewriteRule ^(.)/(img|css|js)/(.) web/$2/$3 [L,QSA]

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.