Jump to:

4876 Posts in 7072 Topics by 1473 members

Installing SilverStripe

SilverStripe Forums » Installing SilverStripe » Friendly url not-working, .htaccess config ? (Infomaniak hosting)

Getting SilverStripe up and running on your computer and on your web server.

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

Page: 1 2
Go to End
Author Topic: 8458 Views
  • Daoro
    Avatar
    Community Member
    5 Posts

    Friendly url not-working, .htaccess config ? (Infomaniak hosting) Link to this post

    Hi all,

    I'm currently trying to install Silverstripe on my Infomaniak.ch host plan.
    I renamed every HTTPResponse instance to something else successfully, preventing conflit with the php config of my host.

    Now I have a problem with mod_rewrite.
    The installation goes fine until :

    Friendly URLs are not working. This is most likely because mod_rewrite isn't configuredcorrectly on your site. Please check the following things in your Apache configuration; you may need to get your web host or server administrator to do this for you:

    * mod_rewrite is enabled
    * AllowOverride All is set for your directory

    I've asked my host about that, and their answer was :

    mod_rewrite is only supported via the .htaccess file.
    We don't give access to the vhost configuration and we don't change it.
    While using mod_rewrite in .htacces, just be careful not to start the path regular expressions with "/".

    Here's my .htaccess (the silverstripe files are located at /ss ) :


    ### SILVERSTRIPE START ###
    <Files *.ss>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
    </Files>

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /ss

    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]
    </IfModule>
    ### SILVERSTRIPE END ###

    Any idea ? I'm really lost with all those rules and still don't understand them

    Thanks !

  • FungshuiElephant
    Avatar
    Community Member
    57 Posts

    Re: Friendly url not-working, .htaccess config ? (Infomaniak hosting) Link to this post

    Post deleted because it contained an error.

  • FungshuiElephant
    Avatar
    Community Member
    57 Posts

    Re: Friendly url not-working, .htaccess config ? (Infomaniak hosting) Link to this post

    If your ISP support/installed Silverstripe then they should be able to help you with their servers.

    There are lots of docs and examples of .htaccess files on the web, your ISP probably has some examples too.

  • Daoro
    Avatar
    Community Member
    5 Posts

    Re: Friendly url not-working, .htaccess config ? (Infomaniak hosting) Link to this post

    Nothing worked, and adding the AllowOverride got me an error 500 :/
    And the .htaccess file was generated by the 2.3.1 installation.

  • FungshuiElephant
    Avatar
    Community Member
    57 Posts

    Re: Friendly url not-working, .htaccess config ? (Infomaniak hosting) Link to this post

    Yep, sorry about that, I got mixed up between the .htaccess in the silverstripe directory, which looks exactly like your original post, and my own .htaccess files one level up that I need because I have multiple things happening on my server.
    I've deleted/modified the contents of my first posts because it's misleading to others that find this page.

    If you go one level up into the root directory of your site there should be an .htaccess file there too. What does that say?

  • Daoro
    Avatar
    Community Member
    5 Posts

    Re: Friendly url not-working, .htaccess config ? (Infomaniak hosting) Link to this post

    I don't have one in the root folder.
    Should I create one, but filled what may I fill it with ?

  • FungshuiElephant
    Avatar
    Community Member
    57 Posts

    Re: Friendly url not-working, .htaccess config ? (Infomaniak hosting) Link to this post

    I'm back in front of my server now and it seems I'm talking rubbish:

    The .htacess files control the access and stuff like rewriting of URLs.
    I don't have .htaccess in my root because I don't need to do any of that stuff for my root directory. You don't need it either (but it was worth checking to see if there was one in case it explicitly forbid something.)

    The /ss directory should contain a .htaccess file and it should look pretty much like your original post (see later).

    All good so far.

    I have a Linux server and in /etc/httpd/conf.d I have a config file that contains the line:

    AllowOverride All


    which allows me to use .htaccess files in the folders of my site. Without this line the server would ignore the .htaccess line in my /ss directory and url rewriting wouldn't work. You won't have access to this config file because you're probably on a shared host and it doesn't matter because it will be set up that way anyway. This is just by way of an explanation as to why I set off down this route earlier.

    So, coming full circle here, we're back to the original .htaccess file.
    I think the line:

    RewriteBase /ss


    is possibly wrong. It causes the rewrite engine to take a url like http://mysite.com/ss and turn it into http://mysite.com which is probably the opposite of what you want.

    If you wanted your pages to be like this:
    http://www.mysite.com/page1/
    then I think you need:

    RewriteBase /


    and further down:

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

    This should cause a page request like:
    http://www.mysite.com/page1/
    to become:
    http://www.mysite.com/ss/sapphire/main.php?url=page1
    which should be correct. You can try this yourself with your own page name.

    I may not have got the RewriteBase bit right (basically you don't need it) so it could be RewriteBase followed by a slash, nothing, or with the line omitted altogether. I can't test it here without breaking my server and that would be bad.

    Hope that makes sense. If your situation is different, then we'll need to know exactly where the silverstripe directory is and what you want your rewritten urls to look like. It's also worth testing to see if you can see unrewritten urls like http://www.mysite.com/ss/sapphire/main.php?url=page1

  • FungshuiElephant
    Avatar
    Community Member
    57 Posts

    Re: Friendly url not-working, .htaccess config ? (Infomaniak hosting) Link to this post

    If you get it working then it may be worth having a read around security; it's generally not a good idea to have code (ie silverstripe) in a publicly accessible web directory because then I might be able to access something you didn't intend me to have access to, config files and the like.)

    Better to put the ss directory in a directory outside of the web root and use the .htaccess files to control the redirection. The Rewrite rule would then look something like:
    RewriteRule .* ../ss/saphire/main.php............................rest of that line.

    Get it working first. ;-)

    8458 Views
Page: 1 2
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.