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.

Customising the CMS /

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

Use standalone PHP in a subdirectory


Go to End


19 Posts   6924 Views

Avatar
SilverRay

Community Member, 167 Posts

3 June 2009 at 4:46pm

Edited: 03/06/2009 4:47pm

Ah, got you. Because of Ingo's wording I actually thought he meant the file itself (Sorry about that ;)

Clear! And thanks, because I actually need this exact functionality for a shopping cart that wants to look into a .php file in some directory in order to do url replacement so the store looks like it is under the real site's domain...

Avatar
borriej

Community Member, 267 Posts

1 June 2010 at 9:42pm

Edited: 01/06/2010 9:50pm

RewriteCond %{REQUEST_URI} !/directoryname

doesn't work for me. Added this rule in my .htaccess, which is in the root. Replaced directoryname for my oscommerce admin folder (www.mydomain.com/catalog/admin)

But i always get the SS error: page not found, but it does exist
Also see: http://www.silverstripe.org/general-questions/show/285405?start=0#post285464

htaccess code:

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

htaccess looks like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

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

RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_URI} !/http://www.mydomain.nl/webshop/catalog/admin/

</IfModule>

### SILVERSTRIPE END ###

Why doens't it work?

Avatar
Willr

Forum Moderator, 5523 Posts

1 June 2010 at 10:20pm

@borriej you have to have all the conditions before the rules in the .htaccess file AFAIK.

Avatar
borriej

Community Member, 267 Posts

1 June 2010 at 10:23pm

@Willr, thankyou for your reply.

Im new to this: which are the other conditions?

Avatar
Willr

Forum Moderator, 5523 Posts

1 June 2010 at 10:32pm

Iin your file

RewriteCond %{REQUEST_URI} ^(.*)$ 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L] 
RewriteCond %{REQUEST_URI} !/http://www.mydomain.nl/webshop/catalog/admin/

I think it needs to be like

RewriteCond %{REQUEST_URI} ^(.*)$ 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/http://www.mydomain.nl/webshop/catalog/admin/
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L] 

All the RewriteCond which are Rewrite Conditions *before* the rule

Avatar
borriej

Community Member, 267 Posts

1 June 2010 at 10:40pm

Ok re-ordered the lines, but it still says: page not found.

Avatar
Willr

Forum Moderator, 5523 Posts

1 June 2010 at 10:45pm

Try using a sub folder name instead of your the full url last condition.

RewriteCond %{REQUEST_URI} !^/webshop/catalog/admin

Avatar
borriej

Community Member, 267 Posts

1 June 2010 at 11:01pm

sorry, but that also doesn't work.

Is this really the way to exclude SilverStripe from looking into some folders?

Is there another way to make sure SS doesn't say 'page not found' in 'Non-SilverStripe-Folders?'