1

I have inherited a web application written in PHP. The code is not the best and I want to start using the Symfony framework. It will be a gradual migration through several releases so I need the legacy pages, web scripts, css files and images to work as they do now.

My plan is to put a Symfony installation in a sub directory of the project's root and set the Apache2 config's document root to the Symfony directory. Then I need to set up Apache2 to serve the legacy scripts from the old document root. Here's a before and after of the directory structure.

Before:

lib
htdocs
htdocs\index.php
htdocs\img\logo.png
htdocs\css\styles.css
sql-updates

After:

lib
htdocs
htdocs\index.php
htdocs\img\logo.png
htdocs\css\styles.css
sql-updates
symfony
symfony\app.php

htdocs is the current document root and symfony will be the new document root.

Symfony pretty much works through the app.php script so most requests for Symfony code will go through that.

If any requests for pages or files are not found in the symfony directory I want Apache to look in the htdocs directory as it did before.

Is there a way to do this without moving the URIs for the legacy pages to a sub directory?

E.g. If the previous URI was www.app.com/ascript.php and it resolved to htdocs/ascript.php I don't want to have to change the URI to something like www.app.com/legacy/ascript.php.

Is this possible?

0

This should be pretty straightforward, there is even an example in the manual:

http://httpd.apache.org/docs/2.4/rewrite/remapping.html#multipledirs

  • That's for where both directories are in the document root. – emurano Aug 23 '15 at 22:42
  • As long as you add a <Directory>; block that allows the files to be served, you can tell rewrite to look for them and/or serve them. – covener Aug 23 '15 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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