Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

[solved] modifying .htaccess for site update


5 Posts   833 Views


24 March 2011 at 11:33pm (Last edited: 24 March 2011 11:49pm), Community Member, 89 Posts


right now i have a silverstripe installation in a subfolder of root: /cms
i use two .htaccess files, one in root, the other one in /cms - so the user doesn't know he's actually in /cms

now i would start working on a update and would like to install a new version of ss to another folder: /cms_2.4

so i would like the visitors still see my old site, but my ip should redirect to the new one in /cms_2.4

my .htaccess in webroot is:

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /cms/   
   RewriteCond %{REQUEST_URI} !^/cms/
   RewriteRule ^(.*)$ /cms/$1

i would like to have something like that:

if !myip
   goto /cms
   goto /cms_2.4

how are the new redirect rules?



25 March 2011 at 12:30am Forum Moderator, 1796 Posts

right here...


25 March 2011 at 1:41am (Last edited: 25 March 2011 2:55am), Community Member, 89 Posts

right, i also found this thread... but it doesn't tell me where to copy the lines of code. and: do i have to modify the existing .htaccess or is it enough to add the mentioned code.

this only applys to when i want to redirect to a file.
but i want to switch the directory.


25 March 2011 at 4:19am Forum Moderator, 1796 Posts

sorry about that, I don't know, but I'd read this if I needed to learn more about it


25 March 2011 at 5:36am (Last edited: 25 March 2011 7:22am), Community Member, 89 Posts

just to recapitulate:

i want different silverstripe installation in the same webroot, in separate subfolders like: httpdocs/cms_2.3 or httpdocs/cms_2.4
i want urls, that look like: and not
i want to work on one silverstripe installation, cms_2.4, but all users be redirected to cms_2.3

when finished working on cms_2.4 i want to switch to cms_2.4 without anyone notice, of course. :)

so, i went and installed my silverstripe versions in the appropriate folders.
then, i changed /cms_2.3/.htaccess and /cms_2.4/.htaccess

from (example of /cms_2.3/.htaccess):

   RewriteBase /cms_2.3


   RewriteBase /

then i added a .htaccess file to webroot:

<IfModule mod_rewrite.c>
   RewriteEngine On
   #change to your ip
   RewriteCond %{REMOTE_HOST} ^127\.0\.0\.1$
   RewriteRule ^(.*)$ /cms_2.4/$1 [L]
   RewriteRule ^(.*)$ /cms_2.3/$1 [L]

then i had to modify _config.php in yourSite folder. just add this line of code to the end:


now, everyone not coming from is redirected to cms_2.3, and i can work on cms_2.4. when finished, i just change

RewriteRule ^(.*)$ /cms_2.3/$1 [L]


RewriteRule ^(.*)$ /cms_2.4/$1 [L]

and start workin on cms_2.5 :D

actually, i only tested it on my wamp server installation. when i come home, i will test it on a live site.