Jump to:

22997 Posts in 11844 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » [solved] modifying .htaccess for site update

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

Page: 1
Go to End
Author Topic: 759 Views
  • marcink
    Avatar
    Community Member
    89 Posts

    [solved] modifying .htaccess for site update Link to this post

    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

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts
  • marcink
    Avatar
    Community Member
    89 Posts

    Re: [solved] modifying .htaccess for site update Link to this post

    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.

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: [solved] modifying .htaccess for site update Link to this post

    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

  • marcink
    Avatar
    Community Member
    89 Posts

    Re: [solved] modifying .htaccess for site update Link to this post

    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

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

    759 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.