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


Reply


5 Posts   853 Views

Avatar
marcink

Community Member, 89 Posts

24 March 2011 at 11:33pm

Edited: 24/03/2011 11:49pm

hi,

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
</IfModule>

i would like to have something like that:

if !myip
   goto /cms
else
   goto /cms_2.4

how are the new redirect rules?

thanks

Avatar
swaiba

Forum Moderator, 1799 Posts

25 March 2011 at 12:30am

right here...
http://www.silverstripe.org/general-questions/show/14725

Avatar
marcink

Community Member, 89 Posts

25 March 2011 at 1:41am

Edited: 25/03/2011 2:55am

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.

Avatar
swaiba

Forum Moderator, 1799 Posts

25 March 2011 at 4:19am

sorry about that, I don't know, but I'd read this http://httpd.apache.org/docs/2.0/misc/rewriteguide.html if I needed to learn more about it

Avatar
marcink

Community Member, 89 Posts

25 March 2011 at 5:36am

Edited: 25/03/2011 7:22am

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: mydomain.com/page1 and not mydomain.com/cms_2.3/page1
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


to:

   RewriteBase /

then i added a .htaccess file to webroot:

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

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

Director::setBaseURL("/");

now, everyone not coming from 127.0.0.1 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]

to

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.