0

I use the built in php server most often when developing locally.

drupal server

Is there any tweak I could make locally to have all my assets referenced on the live site? When I ran apache locally I use to put this in the vhost file.

<IfModule mod_rewrite.c>
  RewriteEngine on
  rewriteCond %{DOCUMENT_ROOT}/sites/%1/files/%2 -f
  rewriteRule ^(.*)$ $1 [QSA,L]
  # Otherwise, send anything else that's in the files directory to the
  # production server.
  rewriteCond %{REQUEST_URI} ^/sites/[^\/]*/files/.*$
  rewriteCond %{REQUEST_URI} !^/sites/[^\/]*/files/css/.*$
  rewriteCond %{REQUEST_URI} !^/sites/[^\/]*/files/js/.*$
  rewriteCond %{REQUEST_FILENAME} !-f
  rewriteCond %{REQUEST_FILENAME} !-d
  rewriteRule ^(.*)$ http://www.livesite.com$1 [QSA,L]
</IfModule>

But now that I'm using the built in server, I can't do that. I was wondering if there may be another way? Preferably without a module that would affect my Drupal site. I just want this as a local modification.

2 Answers 2

1

If I understand this correctly, you can just use the Stage File Proxy module. Configure it to point at your production site. It has more configuration associated to it instead of just rewrite rules (which will be overwritten the next time you update core anyway).

1
  • Thanks. I will definitely go that route if it's the only one available. I would love a local solution that didn't require a module to be installed. But that may not be possible.
    – xpersonas
    Apr 16, 2018 at 19:24
1

So drupal server is a Drupal Console wrapper around Symphony's server:start & PHP's built in web server. As you can see in the Symphony (& PHP) docs, you can configure a router script for the server that adjust the server's output based on the response. If you turn up the verbosity on Drupal console (drupal -vvv server), you'll see debug info that points where Drupal console is retrieving its default wrapper script.

You might be able to do some sort of hackery with the router script to achieve something similar to Apache's redirect/rewrite directives, but you're likely to get something that's not exactly 1:1 due to difference in the PHP/Apache web server.

1
  • Thanks. I forget about -vvv. Not sure what I want is possible through this route, but this does help shed light on how the router works and where it's coming from.
    – xpersonas
    Apr 19, 2018 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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