How do I redirect this right with .htaccess
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]
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]
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.
精彩评论