Short Story- Mod_mono on apache2 handles URL rewriting as long as it is configured correctly.

 

Long Story-  If you don?t use SetHandler in your Host or VirtualHost file requests that do not have a physical file existing on the server will never make it to the mono server and your users will always get a 404 error.  Below is an example of a VirtualHost file that demonstrates how you need to set up your .Net/Mono applications.

VirtualHost file


   1:  <VirtualHost *:80>
   2:      ServerAdmin     email@email.com
   3:      ServerName    blog.site.com
   4:      DocumentRoot "/srv/www/site"
   5:      HostnameLookups Off
   6:      UseCanonicalName On
   7:      MonoApplications blog "blog.site.com:/://srv/www/site"
   8:      <Directory "/srv/www/site">
   9:          MonoSetServerAlias blog
  10:          SetHandler mono
  11:          <FilesMatch "\.(gif||jp?g|png|css|ico|xsl|js|zip|wmv)$">
  12:              SetHandler None
  13:          </FilesMatch>
  14:          AllowOverride None
  15:          Order allow,deny
  16:          Allow from all
  17:      </Directory>
  18:  </VirtualHost>
.

 

ONE LAST THING

If you try to restart apache with the usual command (/etc/init.d/apache restart) you will most likely get an error saying that you can?t connect to the mono dashboard.  To overcome this you need to Enable and then Disable the apache service after editing your VirtualHost file.  This can be done in openSUSE by going to ?>Yast->Services.  I am not sure about Ubuntu.

Submit this story to DotNetKicksShout it   Bookmark and Share