Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Upgrade and htaccess

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 2107 Views
  • tracerround
    Avatar
    3 Posts

    Upgrade and htaccess Link to this post

    I upgraded from v2.1 to v2.2. My upgrade did not go as outlined in the docs. The v2.1 was in a directory called silverstripe (public_html/silverstripe/) and I had a non-ss website in the home directory. I removed the old non-ss site and uploaded a fresh download of v2.2 to the home directory (public_html/). I copied and overwritten all the folders except for cms, sapphire and jsparty. When I went to the main page, it gave me the install screen. I tried accessing www.mysite.com/db/build?flush=1 and I got Page not found. After repeating the process again, still same message. So I entered the exisiting database info into the install screen on the main site and installed v2.2. The site works and the new version is showing along with my template and such from the v2.1 site. After testing everything out, all works as desired except for one BIG thing.

    My subdomains do not work anymore. I have an instance of Roundcube installed in /public_html/webmail/ and when I go to webmail.mysite.com it says /public_html/sapphire/main.php can not be found. There is no reason for Roundcube to want that file (and the file is there).

    My .htaccess makes a call to that file so I think it maybe something to do with permissions. I remove the SS stuff out of my .htaccess from my home directory and my Roundcube and other subdaomins work again but now my site does not.

    I have to have both and it seems that my home directory .htaccess file is blocking all the directories but the ones SS uses. How do I fix this?????

    Thank you for the help.

  • DesignCity
    Avatar
    38 Posts

    Re: Upgrade and htaccess Link to this post

    This is a mod_rewrite issue. The default .htaccess file looks like this:

    ### SILVERSTRIPE START ###
    RewriteEngine On

    RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    ### SILVERSTRIPE END ###

    That last line redirects all files to saphire/main.php with the file you were looking for appended as a query string. What you need to to is exclude a directory from the rewrite, like so:

    ### SILVERSTRIPE START ###
    RewriteEngine On

    RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f

    # Exclude Directories from mod_rewrite
    RewriteRule ^(excludedir1¦excludedir2¦excludedir3) - [L]

    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    ### SILVERSTRIPE END ###


    Obviously change excludedir1 (etc) to the name of the directory you want to exclude from mod_rewrite (in your case this would be "webmail"), and it should stop SS taking over the directory.

    And finally some keywords for anyone searching a solution to the same issue:
    access sub-directories, sub-directory, block directory, block other directories, htaccess, .htaccess, mod_rewrite, allow directory.

  • tracerround
    Avatar
    3 Posts

    Re: Upgrade and htaccess Link to this post

    Thank you for the help. I knew it had to do with the htaccess file but I did not know how to exclude the directories.

    I tried your fix and it breaks my entire site. Pretty much removes all of the templates and all you see is the site in text. As a temp fix, I have been redirecting my site to the subdirectory /silverstripe/ and it was working until I uploaded the new .htaccess file. Now for some reason it wont keep the redirect (not sure if that would be a different cause. I do use a subdirectory /cpanel/ to access cPanel).

    This is what I have in my .htaccess file:

    AddHandler application/x-httpd-php5 .php
    SecFilterEngine off
    ### SILVERSTRIPE START ###
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f

    # Exclude Directories from mod_rewrite
    RewriteRule ^(webmail) - [L]

    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    ### SILVERSTRIPE END ###

    I have been putting # in front of RewriteRule ^(webmail) - [L] to make the site look correct and not text.

  • tracerround
    Avatar
    3 Posts

    Re: Upgrade and htaccess Link to this post

    Thanks to the help of jam13 on the IRC channel, we got it working. I needed to move the RewriteRule up higher in the .htaccess file.

    This works for me:

    AddHandler application/x-httpd-php5 .php
    ### SILVERSTRIPE START ###
    RewriteEngine On
    RewriteRule ^(webmail|fts) - [L]
    RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    ### SILVERSTRIPE END ###

    This stops the .htaccess file from pushing the /webmail/ and /fts/ directories from looking for the /sapphire/main.php files to function.

    Thanks again for your help jam13 and DesignCity.

  • DesignCity
    Avatar
    38 Posts

    Re: Upgrade and htaccess Link to this post

    Great that you got it working. The solution I presented above worked when I tested it on a couple of my sites, so I find it bizarre that it didn't work on yours! Mod_rewrite is a strange beast - I don't think there are many people about who truely understand all the little quirks with it!

    2107 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.