hhvm fastcgi and apache .htaccess rules - apache

Ok so I have this rewrite rule:
RewriteRule ^images/$ index.php?id=images [L]
So hhvm instead of using this rule it searches first for the images folder and looks for a index.php file
I'm using this proxy directive in the virtual host file:
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/hhvm/mydomain/htdocs/$1
What can be done so this rule can work correctly even if the folder images exists ?
Thanks,

Related

Redirect sub-folder to another folder

I need to redirect the content of domain.com/app1 to domain.com/apps/app1, but keep the url domain.com/app1.
How to do that?
Is it possible to do via .htaccess file, or should I modify httpd.conf file, add some VirtualHost ...?
Thanks.
You can use this rule in http or virtual host config:
RewriteEngine On
RewriteRule ^/?app1(/.*)?$ /apps%{REQUEST_URI} [L,NC]
You may use this rule in site root .htaccess as well.

Htaccess rewrite to file located up one level

I have an htaccess in a subdomain with the following rule:
RewriteEngine On
RewriteBase /
RewriteRule ^feed([0-9]+)$ ../image.php?id=$1 [L]
So basically I want to redirect requests from feed which is located in a subdomain to image.php file which is located in the main domain (just one directory above). Using ../ doesn't seem to work like in PHP.
So how can I rewrite to file in the parent directory?
Thanks!
You can use mod_alias for this. Add the following directive to .htaccess file of subdomain:
AliasMatch "^/feed([0-9]+)$" "/absolute/path/to/image.php?id=$1"
Alternatively you can use symbolic links, but in my opinion AliasMatch directive is better.

Apache ignore *.php files in rewrite directives but not other extensions

I'm trying to test some simple rewrite directives in .htaccess file on my test environment with Apache and PHP-FPM.
It seems that a simple rewrite rule works well for any type of file but not for *.php files.
This works :
RewriteEngine On
RewriteRule ^sandbox/video\.html?$ http://www.google.fr? [R,L]
But this not :
RewriteEngine On
RewriteRule ^sandbox/video\.php?$ http://www.google.fr? [R,L]
I run Apache 2.2 and PHP-FPM inside a VM on Debian
Could it be related ?
Thanks for your help
With PHP-FPM the .htaccess file is never read for php URL. You will need to add the rewrites to your main config.

rewrite rules not working

I use some rewrite rules inside the Apache virtual hosts configuration httpd-vhosts.conf and it works fine there. Because I want to move to a managed server I have to use the .htaccess file because I don't have access to the apache configuration files.
I tried it locally and somehow I don't get this working at all.
Locally I use xampp 1.8.3 (Apache 2.4.10). I put the .htaccess file in the root directory of the virtual host and use this lines for testing
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule /testrule /about/about.php [L]
I always get an 404 error when calling localhost/testrule
It works fine when I put it in the httpd-vhosts.conf.
mod_rewrite is enabled and I have set AllowOverride All in the Directory part.
This blog post clearly mention
In VirtualHost context, The Pattern will initially be matched against
the part of the URL after the hostname and port, and before the query
string (e.g. “/app1/index.html”).
In Directory and htaccess context, the Pattern will initially be
matched against the filesystem path, after removing the prefix that
led the server to the current RewriteRule (e.g. “app1/index.html” or
“index.html” depending on where the directives are defined).
So in virtual host context, matches start from /testrule/...
While in .htaccess and <Directory/> context, it matches testrule/...
You can quick check the htaccess rewrite rules here:
http://htaccess.madewithlove.be/ or here:
http://martinmelin.se/rewrite-rule-tester/
Just get rid of the leading slash in the RewriteRule and you are done
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule testrule /about/about.php [L]

Moving Joomla SEF rules from .htaccess to vhosts.conf

I have a joomla install which uses the built in SEF urls, and the stock .htaccess file to rewrite them.
I presume that it would be much more efficient to set the rules in the apache config rather than .htaccess, [to avoid having this file requested and parsed for every file load] but am having trouble finding a reference for it,
So I moved the rules from .htaccess to the vhosts.conf file.
I am now getting 400 bad requests for the pages with the SEF urls.
Can anyone suggest what the issue or offer any suggestions ?
UPDATE
It seem that the base was the issue, just need to change the rewrite rule from:
RewriteRule .* index.php [L]
to
RewriteRule .* /index.php [L]
where in the vhosts.conf file have you placed these rules? they should be in the
<Directory /path/to/joomla>
#your rules here
</Directory>
inside the Vhost definition