CodeIgniter Forums
Single RewriteRule for root and subdirectory deployments? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Single RewriteRule for root and subdirectory deployments? (/showthread.php?tid=4341)



Single RewriteRule for root and subdirectory deployments? - El Forum - 11-19-2007

[eluser]jabbett[/eluser]
I have a CodeIgniter application which I need to deploy in multiple environments through the software development lifecycle (dev, test, staging, production). In the earlier environments, the software runs off a subdirectory of the web server, e.g. http://localhost/~username/index.php, and in the later environments, it runs on a dedicated web server, e.g. http://www.myapplication.com/index.php.

Ideally, I'd like to include a single htaccess file that will work automatically in both environments. So far, I've been forced to change the RewriteBase value in each setting.

Development
Code:
RewriteEngine On
RewriteBase /~username/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1

Production
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1

Is there any way around this, or will I need to maintain unique htaccess files for each deployment?

Thanks in advance.