To this end a post-deployment action can be added to fix the RewriteBase directive in the '.htaccess' file. In a previous post, application deployment scripts were used to help chmod application's resources. This time I am going to use deployment hooks to modify the RewriteBase directive automatically after deploying the Symfony2Cloud application.
In the deployment script you can find this code:
<?// get application location$appLocation = getenv('ZS_APPLICATION_BASE_DIR');
// modify htaccess$htaccess_file = $appLocation . '/web/.htaccess';$explode = explode ( '/', $appLocation );$appname = $explode [sizeof ( $explode ) - 2];
$content = file_get_contents ( $htaccess_file );$content = str_replace ( '<application-name>', $appname, $content );file_put_contents ( $htaccess_file, $content );
In details: The application location is used to resolve its alias. Then the alias name is used to replace the .htaccess file content so instead of "RewriteBase /<application-name>
Assuming that you use Zend SDK and the following deploy command:
zend deploy application -r git://github.com/ganoro/Symfony2Cloud.git
Symfony2Cloud is now deployed and ready to use with this .htaccess:
<IfModule mod_rewrite.c> RewriteBase /Symfony2Cloud RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ app_dev.php [QSA,L] </IfModule>
No comments:
Post a Comment