Deploying app under Drupal

Hi everyone,

I’ve developed an app that will sit on the same server as a running Drupal install and am finding that the rewrite rules for the Drupal site to enable search friendly links is grabbing all the requests.

Here’s what my www root looks like:

webroot

|.htaccess

|myapp

|yii

|drupal files

in my .htaccess file, i’ve got the following in the mod_rewrite section:

stuff to let through (ignore)

RewriteCond %{REQUEST_URI} myapp

RewriteRule (.*) $1 [L]

Rewrite current-style URLs of the form ‘x’ to the form ‘index.php?q=x’.

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !=/favicon.ico

RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Rewrite non www url to www url

RewriteCond %{HTTP_HOST} !^www\…*

RewriteCond %{HTTP_HOST} !^$

RewriteCond %{HTTP_HOST} ^([^.]*)\.(ca)

RewriteRule ^.*$ http://www.%1.%2%{REQUEST_URI} [R=permanent,L]

Now if I go to www.mydomain.ca/myapp, i get the default page for my Yii app. If I go to any other url in the app, I get redirected to Drupal, for example: www.mydomain.ca/myapp/site/login, will redirect me to www.mydomain.ca

Can anyone shed any light on this?

Thanks!

james

Ok, I figured it out, but I’ll post the solution here just in case anyone else needs it.

Turning off clean URLs in my Yii app seemed to work, so tried to do clean URLs using .htaccess instead of Yii. But instead of trying to do everything in the one .htaccess file, and I would create a new one within my app: wwwroot/myapp/.htaccess

In this .htaccess file I have:

Various rewrite rules.

<IfModule mod_rewrite.c>

RewriteEngine on

Options +FollowSymLinks

IndexIgnore /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

</IfModule>

Now it all works!

I’m no expert with mod_rewrite, so the credit goes here: http://www.thewayofcoding.com/2009/11/clean-urls-in-php-yii-framework/