php - How to "move" the document root up one level to the public directory? -
i copy rewrite code post zend.
rewriteengine on rewriterule ^\.htaccess$ - [f] rewritecond %{request_uri} ="" rewriterule ^.*$ /public/index.php [nc,l] rewritecond %{request_uri} !^/public/.*$ rewriterule ^(.*)$ /public/$1 rewritecond %{request_filename} -f rewriterule ^.*$ - [nc,l] rewriterule ^public/.*$ /public/index.php [nc,l]
the idea of move document root 1 level public directory without touching or modifying virtual host file.
so tested on dummy project on localhost see if works on local machine. but not. still have click on public folder see web content.
this directories,
.htaccess public/ .htaccess index.php
index.php,
<?php // show information, defaults info_all phpinfo();
and tested on live server well. rewrite code not move document root 1 level public directory @ all.
any ideas have missed?
i tested on zend (zend 2) project , not work too. , still have click on public folder see web content.
any ideas?
edit:
content of /public/.htaccess
rewriteengine on # following rule tells apache if requested filename # exists, serve it. rewritecond %{request_filename} -s [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d rewriterule ^.*$ - [nc,l] # following rewrites other queries index.php. # condition ensures if using apache aliases # mass virtual hosting, base path prepended # allow proper resolution of index.php file; work # in non-aliased environments well, providing safe, one-size # fits solution. rewritecond %{request_uri}::$1 ^(/.+)(.+)::\2$ rewriterule ^(.*) - [e=base:%1] rewriterule ^(.*)$ %{env:base}index.php [nc,l]
i have use url see web page,
http://{localhost}/a-project/public/
instead of,
http://{localhost}/a-project/
it same on live server, have use
http://my-website.com/public/
instead of,
http://my-website.com/
i thought .htaccess in root can move document root 1 level public directory without touching or modifying virtual host file, it cannot obviously...
try rule in documentroot
.htaccess:
rewriteengine on rewritebase / rewritecond %{request_filename} -f rewriterule (.*) public/$1 [l]
Comments
Post a Comment