Jump to:

4938 Posts in 16566 Topics by 1490 members

Installing SilverStripe

SilverStripe Forums » Installing SilverStripe » .htaccess mod to remove /ss/ subdirectory from url?

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: 5914 Views
  • AlaVive
    Avatar
    Community Member
    42 Posts

    .htaccess mod to remove /ss/ subdirectory from url? Link to this post

    Hi, all.

    I've installed Silverstripe on a shared host within a "ss" subdirectory. It currently works fine to show the site landing page at www.mysite.com, but all the page appear as "www.mysite.com/ss/page."

    If I enter "www.mysite.com/page," it shows fine, but the links don't default to that. I don't know what to change (anywhere) to remove the "ss" from the url.

    There are two .htaccess files after installation: one in the root directory:

    ### 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$)

    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    </IfModule>
    ### SILVERSTRIPE END ###

    ...and one in the "ss" subdirectory:

    # Use PHP5CGI as default
    AddHandler fcgid-script .php

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

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    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 ###

    1) Do I NEED both?
    2) Is there a quick solution via .htaccess that doesn't require that I actually MOVE any files? I've searched the forums and the rest of the WWW, but I'm more confused now than when I started.

    Thanks!

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: .htaccess mod to remove /ss/ subdirectory from url? Link to this post

    There's a solution by using virtual hosts, so you can put the site wherever in the web root but still have mysite.com go to it. You might want to read up on this Apache feature, since it's very useful!

    e.g.

    <VirtualHost *:80>
    ServerName mysite.com
    ServerAlias www.mysite.com
    DocumentRoot "/var/www/mysilverstripesite"
    </VirtualHost>

    You also don't need two .htaccess files. You should only need the one inside your ss directory.

    Sean

  • AlaVive
    Avatar
    Community Member
    42 Posts

    Re: .htaccess mod to remove /ss/ subdirectory from url? Link to this post

    Thanks, Sean.

    Please forgive me if I'm an utter dork. But, I don't understand.

    Isn't this something I have to change in the httpd.conf file? I don't have access to it via the shared hosting account.

    If I remove the root (public_html) .htaccess, the site breaks. And, when I modify the .htaccess in the public_html/ss/ directory, it changes nothing.

    If it was requiring every address be entered as "www.mysite.com/ss," I think I could wrap my mind around it a bit better. However, the site works correctly by entering "mysite.com" or entering "mysite.com/about."

    The problem (for the people I have to please) is that the only way to access the CMS admin is through "mysite.com/ss/admin" (the Security admin will DISPLAY at mysite.com/admin, but it doesn't work) and that, when navigation is selected in the site, the link url is displayed as "mysite.com/ss/about" or "mysite.com/ss/contact."

    They want "ss" gone from the url, altogether.

    Am I just misunderstanding something?

    Thanks again!

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: .htaccess mod to remove /ss/ subdirectory from url? Link to this post

    I'm not sure who your host is, but when I was on DreamHost they provided me a directory that I could put files in e.g. /home/myusername/mysite.com and then they'd be accessible through mysite.com. Surely there's some mechanism provided by your host to point domains to directories inside your webroot. Have you checked with them?

  • HendriksenRemco
    Avatar
    Community Member
    1 Post

    Re: .htaccess mod to remove /ss/ subdirectory from url? Link to this post

    Hi there! I also had this problem. But there is a really simple fix for this provided by Silverstripe.
    It's the function Director::setBaseURL("http://www.example.com/"). Put that function in your _config.php and your problem should be away.

  • MartinPhone
    Avatar
    Community Member
    57 Posts

    Re: .htaccess mod to remove /ss/ subdirectory from url? Link to this post

    Hello - I have exactly the same problem as the OP - what was your solution? When I try the Director:: line it breaks the CSS. What's the right thing to do?!

  • MitraX
    Avatar
    Community Member
    20 Posts

    Re: .htaccess mod to remove /ss/ subdirectory from url? Link to this post

    Hi there! I also had this problem. But there is a really simple fix for this provided by Silverstripe.
    It's the function Director::setBaseURL("http://www.example.com/"). Put that function in your _config.php and your problem should be away.

    The problem with this "solution" is that it is not possible to log in to CMS admin. This is very annoying behavior.

  • Dazman1
    Avatar
    Community Member
    30 Posts

    Re: .htaccess mod to remove /ss/ subdirectory from url? Link to this post

    Hi

    Have you tried changing you .htaccess file in the root of your site to
    ### SILVERSTRIPE START ###
    <Files *.ss>
       Order deny,allow
       Deny from all
       Allow from 127.0.0.1
    </Files>

    <Files web.config>
       Order deny,allow
       Deny from all
    </Files>

    ErrorDocument 404 /assets/error-404.html
    ErrorDocument 500 /assets/error-500.html

    <IfModule mod_alias.c>
       RedirectMatch 403 /silverstripe-cache(/|$)
    </IfModule>

    <IfModule mod_rewrite.c>
       SetEnv HTTP_MOD_REWRITE On
       RewriteEngine On
       RewriteBase /

       RewriteCond %{REQUEST_URI} ^(.*)$
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    </IfModule>
    ### SILVERSTRIPE END ###

    if your site is in the root directory leave the rewrite base, if in a sub directory ie yoursite.com/ss
    change RewriteBase to RewriteBase/ss

    Let me know

    Darren

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