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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Installing SilverStripe /

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

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

Hide the subdirectory silverstripe is in


Go to End


6 Posts   3478 Views

Avatar
coffeymachine

Community Member, 10 Posts

14 November 2009 at 9:08am

What's up?

I have installed SilverStripe into a subdirectory on my web server, and I want my domain name to go straight to SilverStripe so I can use other subdirectories for other domain names I am going to get in the future. I have successfully been able to point my main domain to the /silverstripe subdirectory, but the problem I have now is when I am browsing through my SilverStripe site it still has /silverstripe in the URL. I want to get rid of this.

e.g.
www.mydomain.com
actually points to
www.mydomain.com/silverstripe
but appears in the browser URL bar as
www.mydomain.com

When I click to say, the About Us page, the URL becomes
www.mydomain.com/silverstripe/about-us/

Is there a way to modify the .htaccess file to simply hide "/silverstripe" from the browser's URL bar?
Another approach might be to somehow modify SilverStripe's base URL, although I've read around the forums that people have run into problems with this approach.

This seems like it should be a very simple thing to do, but I spent hours yesterday Googling this to no avail. Any help would be appreciated. Thanks!

Avatar
yurigoul

Community Member, 203 Posts

14 November 2009 at 10:07pm

Isn't this something you should discuss with your provider?

And on another note, I do think you can just use your subdirs for other domains even if silverstripe resides in the top domain. The htacccess file in yor public_html folder (or whatever it is called) is ignored for subdomains and addon domains. I have my addon/sub domains in a folder starting with a an underscore so I am sure that no names I can come up with will intervene with those folders (in my case I am using _domains for all my domains).

And since I also sometimes have to give people direct access to some files - and not all of them are comfortable with ftp - I also have the rule RewriteCond %{REQUEST_URI} !^/_.*/.* added to my htaccess

Avatar
anthonyberry

Community Member, 4 Posts

15 November 2009 at 11:49pm

I am having the same problem and can't find an answer anywhere! Any pointers anyone??

Avatar
dhensby

Community Member, 253 Posts

16 November 2009 at 3:31am

Right, I'm no .htaccess expert, but this is my take on it.

If you were able to get the htaccess folder in the root of your public_html to check the http_host and then determine if it is the SS domain, it would apply slightly modified SS htaccess rules.

This isn't working code, but shows my idea:

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

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTP_HOST} !^exampledomain.com$
RewriteCond %{REQUEST_URI} !(\.gif$)|(\.jpg$)|(\.png$)|(\.css$)|(\.js$) 

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

So the idea is check the domain and then re-write to subdir/sapphire... Hopefully someone with some proper htaccess knowledge will correct this so it's working :)

Avatar
coffeymachine

Community Member, 10 Posts

23 December 2009 at 10:03am

I was never able to figure this out.

I gave up and finally moved all the code to my base directory. Doing that was really easy and didn't cause anything to break. Just be sure you move the .htaccess file with it.

This was never a critical issue, I just wanted to do this for cleanliness and ease of backups down the road. Now all my SilverStripe files and folders are alongside my other unrelated files. It's a little messy but it works.

Avatar
felito

Community Member, 10 Posts

1 August 2013 at 12:40pm

Any update about this?