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

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 stackoverflow.com Oct 8 '11 at 16:51

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

add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.