views:

74

answers:

2

Yeah, Iam trying to make the _PRIVATE folder out from the web itself

I cant figure out how I do a /../ redirect. Because this is happening in Apache it should allow it somehow.

I want ../ because sometimes _PUBLIC is www root, depends on the large sets of webhosts out there, and I want it to work on both setups =/

Structure

/ (www root)
    - .htaccess #1
    - _PUBLIC/
        - .htaccess #2
        - images/
        - javascripts/
        - styles/
     - _PRIVATE/
        - pages/
            - login.php



.htaccess #1
    * -> /_PUBLIC/*

.htaccess #2
    user/login -> /../_PRIVATE/pages/login.php

This is how my .htaccess files looks like now

.htaccess #1
    RewriteCond $1 !^_PUBLIC
    RewriteRule ^(.*)$ /_PUBLIC/$1 [L]

.htaccess #2
    RewriteRule ^user/login/? /../_PRIVATE/pages/login.php [L]
A: 

I think you should drop the first / before your ..

RewriteRule ^user/login/? ../_PRIVATE/pages/login.php [L]

Doesn't that work?

UPDATE:

if you can access _PUBLIC and _PRIVATE as http://yoursite/_PUBLIC and http://yoursite/_PRIVATE then you should just rewrite to

RewriteRule ^user/login/? /_PRIVATE/pages/login.php [L]

END UPATE

Also: you should be able to merge your two .htaccess files by adding the prefix _PUBLIC to the rule in #2 - that way you don't have to use .. at all.

Simon Groenewolt
Hmm, strip out the / didn't work, Iam getting Error 400 (Bad Request). Yeah, there is a reason I havnt merge them that way, the site is going to work with both _PUBLIC as DocRoot but also / (including both _PRIVATE and _PUBLIC)
Markus
Thanks for the quick reply. I appreciate it.
Markus
updated my answer
Simon Groenewolt
A: 

Try these rules:

RewriteCond $1 !^_(PUBLIC|PRIVATE)($|/)
RewriteCond %{THE_REQUEST} !^[A-Z]+\ /_(PUBLIC|PRIVATE)[/?\ ]
RewriteRule ^(.*)$ /_PUBLIC/$1 [L]

RewriteRule ^user/login/? /_PRIVATE/pages/login.php [L]
Gumbo
Thank you, this will indeed work in one scenario (/ is www root). I forgot to add that to the description (have added it now) but sometimes _PUBLIC will be the real www root. and this will not work then I think
Markus
@Markus: You can always use the absolute file system path.
Gumbo