Jump to:

5539 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Use standalone PHP in a subdirectory

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

Page: 1 2 3
Go to End
Author Topic: 4431 Views
  • SilverRay
    Avatar
    Community Member
    167 Posts

    Re: Use standalone PHP in a subdirectory Link to this post

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

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: Use standalone PHP in a subdirectory Link to this post

    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?

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Use standalone PHP in a subdirectory Link to this post

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

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: Use standalone PHP in a subdirectory Link to this post

    @Willr, thankyou for your reply.

    Im new to this: which are the other conditions?

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Use standalone PHP in a subdirectory Link to this post

    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

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: Use standalone PHP in a subdirectory Link to this post

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

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Use standalone PHP in a subdirectory Link to this post

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

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

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: Use standalone PHP in a subdirectory Link to this post

    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?'

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