1

Im having a problem getting zend framework to play nicely with subdomains on my server. I have a LAMP stack running on ubuntu 11.10, I am also using a dynamic dns service where I have my zone records defined. So basically my dns is setup like:

DNS: Registered with one company and point my domain name to the Dynamic DNS's nameservers here.

With the Dynamic DNS host I have 3 defined zone records of type A:

mydomain.com 000.00.0.0
www.mydomain.com 000.00.0.0
*.mydomain.com 000.00.0.0  <-- wildcard to catch all subdomains

Apache setup:

in /etc/apache2/sites-available :: /sites-enabled I have my default setup for mydomain and another vhost for mysubdomain.mydomain.com

/var/www : I have mydomain.com/public /var/www/public folder as its document root

/var/www/mysubdomain : I have mysubdomain.mydomain.com using /var/www/mysubdomain/public folder as its root

I think all of this is setup correctly because I serve any request to www.mydomain.com correctly, and I also serve any request to www.mysubdomain.mydomain.com correctly.

BUT when I make a request like www.mysubdomain.mydomain.com/:controller or www.mysubdomain.mydomain.com/:controller/:action I am issued a 404 Not Found from the server with the following message:

The requested URL /controller/action was not found on this server.

Im thinking this is an issue with my .htaccess which is setup the following way in

my .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php 

The thing is that when the application that I am currently trying to access is setup and accessd as a normal domain like www.mysubdomain.com everything works.

Ulrich Palha
  • 9,411
  • 3
  • 25
  • 31
John
  • 465
  • 1
  • 4
  • 17

1 Answers1

1

I am using the following .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Maybe you could try and provide the results.

Goeran
  • 362
  • 1
  • 2
  • 8
  • Getting a 500 Internal server error with that .htaccess which is weird because if I remember correctly that is the default recommended .htaccess for zf – John Feb 06 '12 at 15:48
  • Can you place a test.php with just in it in the /public folder and see if you can access it? Or are you also getting a 500 for that one? – Goeran Feb 06 '12 at 15:55
  • Have you set `AllowOverride FileInfo` for your vhost in the httpd.conf? This is required to give .htaccess files permission to enable the rewrite engine. – Goeran Feb 06 '12 at 16:02
  • Sorry, found my error. This was a new install of apache I i had to run a2enmod rewrite to enable url rewriting. While my original .htaccess still works I gave Goeran the answer for taking the time. – John Feb 06 '12 at 16:04