I want to make some folder out of root directory ( public_html
). I have shared server linux
with follow directory.
mysite
public_html
tmp
www
and my site directory in my computer( wamp
):
css
js
index.php
htaccess
I want public folder to be placed into public_html
folder in server. 1)how can I include my code using relative paths?
and I have htaccess
file that points all requests to that public/index.php
in my computer.
2)Where should I put my htaccess
in my Shared server linux
?
my htaccess
file:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
You aplication must be running in this time.
Put everything in
/home/mysite
and configure your virtual host to use
/home/mysite/public/
as DocumentRoot. Put the .htaccess in
/home/mysite/public/
You can't traverse out of the document root using relative paths or rewriting in the htaccess file. You can include files from your php script ( index.php
). So what you can do is allow a request for something outside of public_html
to be routed to index.php
, then in php, load the file outside of public_html
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.