14

I needed slim php to work with pretty urls using .htaccess, well no problem.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

Now I ran this using hhvm, fastcgi using this virtual host config.

<VirtualHost *:80>
  ServerName project.dev
  ServerALias www.project.dev
  DocumentRoot /var/www/project
  ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/$1
  <Directory "/var/www/project">
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

Of course, it won't read the .htaccess file, I thought of adding the .htaccess config in virtual host config, but no, it won't work.

Like so:

<VirtualHost *:80>
  ServerName project.dev
  ServerALias www.project.dev
  DocumentRoot /var/www/project
  ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/$1
  <Directory "/var/www/project">
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
</VirtualHost>
Joey Hipolito
  • 3,108
  • 11
  • 44
  • 83
  • 1
    have you looked at hhvm logs ( /var/log/hhvm ) to see the requests? and can you provide that as well? – Sina Jun 23 '14 at 14:17
  • I have, why do you think it is necessary? It's just how to redirect all requests in the `index.php` in a config. It work just fine if on normal php files, so access and error logs don't log anything that has something to do with it. – Joey Hipolito Jun 23 '14 at 14:34
  • @JoeySalacHipolito It sounds like you are saying that you've had an issue and you think that HHVM is the underlying cause. If so you need do two things to get it some attention from the dev team: 1) install the debug build of HHVM. SEE https://github.com/facebook/hhvm/wiki/Prebuilt%20Packages%20for%20HHVM for OS dependant instructions. 2) open an issue describing your problem @ https://github.com/facebook/hhvm/issues?state=open They will instruct you on ways to resolve the problem if possible. – r3wt Jun 28 '14 at 03:58
  • If you don't get an answer here, you might have more luck on [serverfault](http://serverfault.com/help/on-topic). They are more into server configuration. – Sumurai8 Jun 29 '14 at 09:20
  • Just to be sure, was this same htaccess file working without hhvm? And is `ServerALias` a typo? (ALias instead of Alias) – Anthony Jun 30 '14 at 00:49
  • It appears that hhvm is not fully compatible with all htaccess rules : https://github.com/facebook/hhvm/issues/751. Apparently there are hhvm config files for doing this. – Anthony Jun 30 '14 at 02:59
  • @Anthony yes it is just a typo, the .htaccess file, work just fine, the problem here is just about the proper configuration of things.. – Joey Hipolito Jun 30 '14 at 05:36
  • 1
    You need to put the rules in the directory block, per Apache: "Note that it is completely equivalent to put a .htaccess file in a directory /www/htdocs/example containing a directive, and to put that same directive in a Directory section in your main server configuration" [Apache](http://httpd.apache.org/docs/current/howto/htaccess.html) – upful Jul 24 '14 at 01:55
  • I would recommend switching to nginx in this case. HHVM is very friendly with nginx and pretty urls work out of the box immediately. If you need more details do say, I can help you out. – Crembo Jul 30 '14 at 14:49

1 Answers1

1

This isn't really an HHVM issue, more trying to do rewriting at the same time as proxying.

Doing a quick google search yields another answer which might help.

Community
  • 1
  • 1
Paul Tarjan
  • 48,968
  • 59
  • 172
  • 213