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

Friendly url not-working, .htaccess config ? (Infomaniak hosting)


Go to End


13 Posts   16781 Views

Avatar
Daoro

Community Member, 5 Posts

2 April 2009 at 8:59pm

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 ! :)

Avatar
FungshuiElephant

Community Member, 57 Posts

2 April 2009 at 10:41pm

Edited: 02/04/2009 11:21pm

Post deleted because it contained an error.

Avatar
FungshuiElephant

Community Member, 57 Posts

2 April 2009 at 10:44pm

Edited: 02/04/2009 11:22pm

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.

Avatar
Daoro

Community Member, 5 Posts

2 April 2009 at 10:53pm

Edited: 02/04/2009 10:54pm

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

Avatar
FungshuiElephant

Community Member, 57 Posts

2 April 2009 at 11:21pm

Edited: 02/04/2009 11:25pm

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?

Avatar
Daoro

Community Member, 5 Posts

3 April 2009 at 3:15am

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

Avatar
FungshuiElephant

Community Member, 57 Posts

3 April 2009 at 5:01am

Edited: 03/04/2009 5:05am

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

Avatar
FungshuiElephant

Community Member, 57 Posts

3 April 2009 at 5:23am

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. ;-)

Go to Top