douzhi3454 2016-08-18 09:12
浏览 47

如何在php中设置根目录

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 ?

path

.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>
  • 写回答

3条回答 默认 最新

  • drghhp8706 2016-08-18 09:19
    关注

    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
    
    评论

报告相同问题?