art vanderlay
art vanderlay

Reputation: 2463

htaccess with virtualhost not working

I have a local dev Debx64 machine with a number of virtualhosts configured. the primary URL is set as

<VirtualHost *:80>
ServerAdmin [email protected]
ServerName blah.com 
ServerAlias blah.com 
DocumentRoot /home/blah/v1.blah.com 
<Directory /home/blah/v1.blah.com/>
            AllowOverride All
            Order allow,deny
            allow from all
</Directory>
AccessFileName .htaccess  
ErrorLog /home/blah/blah_logs/v1.blah.com.in-error_log
CustomLog /home/blah/blah_logs/v1.blah.com.in-access_log common 
</VirtualHost>

and that redirects to the primary operating VH

<VirtualHost *:80>
 ServerAdmin [email protected]
 ServerName v1.blah.com 
 ServerAlias v1.blah.com 
 DocumentRoot /home/blah/v1.blah.com 
<Directory /home/blah/v1.blah.com/>
            AllowOverride All
            Order allow,deny
            allow from all
</Directory>
AccessFileName .htaccess  
ErrorLog /home/blah/blah_logs/v1.blah.com.in-error_log
 CustomLog /home/blah/blah_logs/v1.blah.com.in-access_log common 
</VirtualHost>

I have a .htaccess set up on v1.blah.com to parse .html as .php

Options +ExecCGI

AddHandler php-fcgi .php .html 
Action php-cgi /home/php5-fcgi
<FilesMatch "^php5?\.(ini|cgi)$">
    Order Deny,Allow
    Deny from All
    Allow from env=REDIRECT_STATUS
</FilesMatch>

This works fine if I access the URL as v1.blah.com, however if I access it as blah.com the .htaccess is not invoked and the .html is served as normal.

What Am I missing? is there something in php.ini that needs to be changed?

Upvotes: 5

Views: 19025

Answers (1)

px4n
px4n

Reputation: 416

Is there a particular reason why you need to have two separate entries for your hosts? Seeing as they both use the same Log Files, and DocumentRoot, could you not add blah.com to the list of ServerAlias' ?

So you would end up with the following configuration below:

<VirtualHost *:80>
ServerAdmin [email protected]
ServerName v1.blah.com
ServerAlias v1.blah.com blah.com 
DocumentRoot /home/blah/v1.blah.com 
<Directory /home/blah/v1.blah.com/>
            AllowOverride All
            Order allow,deny
            allow from all
</Directory>
AccessFileName .htaccess  
ErrorLog /home/blah/blah_logs/v1.blah.com.in-error_log
CustomLog /home/blah/blah_logs/v1.blah.com.in-access_log common 
</VirtualHost>

Upvotes: 8

Related Questions