Reputation: 616
I am developing a website based on MVC Design Pattern.
I need to access to another folder from public
folder but the problem is it recognizes public folder as root directory. I checked path using window.location.pathname
in javascript and it returns /
so it's literally impossible to access to out of root directory.
I guess .htaccess
file redirects the path. can anyone let me know how to set Web
folder as root directory ?
.htaccess in Web
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
.htaccess in public
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
Upvotes: 0
Views: 2620
Reputation: 712
Write this code to set root dir. in your index file. It may help you to web as root.
if(!defined('ROOT_PATH')) define('ROOT_PATH','./'); //root path. Damn directories
define('ROOT_DIR',str_replace('\\\\', '/', realpath(dirname(__FILE__))).'/'); #Get real path for root dir ---linux and windows
print_r(ROOT_DIR);
Upvotes: 2
Reputation: 57
set this path to your index file.
$path = "http://www.yourdomain.com/";
define ( 'PATH', $path );
and every where you can call "PATH" variable in php you can do vardump(PATH);
i hope this is helpfull.. for u
Upvotes: 0
Reputation: 9103
You are not able to access files outside of your webroot with JS. However, you could create a Symlink in your public folder.
ln -s web/your/file web/public/symlink
Upvotes: 2