php - Apache virtual host uri with a dir -
i can not manage setup virtual host on url subdir ... need run project on address this:
http://www.projects.loc/project1/
should mimic installation on web server address like
http://www.someserver.com/projects/project1/
i need adjust redirects '/' goes www.projects.loc/project1/
in hosts.txt have:
127.0.0.1 www.projects.loc
vhosts enabled , httpd-vhosts.conf looks this:
namevirtualhost *:80 <virtualhost *:80> documentroot "d:/projects/project1/public/" servername www.projects.loc/project1/ </virtualhost>
what missing ?
edit: .htaccess looks this:
rewriteengine on rewritecond %{request_filename} -s [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d rewriterule ^.*$ - [nc,l] rewriterule !\.(js|ico|gif|jpg|png|css)$ index.php [nc,l]
the application running on clean domain, can not manage config run on domain.com/some_dir/
edit: solved this!
namevirtualhost *:80 <directory "d:/projects"> allow </directory> <virtualhost *:80> documentroot "d:/projects" servername www.projects.loc/ alies /project1 /project1/public/ </virtualhost>
note: minimal configuration development environment, check accepted ansler @m-z total details production evironment.
probably solved question. anyway, looking today similar thing, hence document solution here:
you don't want write slashes in servername servername www.projects.loc/project1/
if have 1 project, called "project1", can job done "serverpath", vhost configuration this:
<virtualhost *:80> servername projects.loc serveralias www.projects.loc serverpath /project1/ documentroot /path/public_html errorlog /path/error_log customlog /path/access_log combined directoryindex index.html index.htm index.php index.php4 index.php5 <directory /path/public_html> options -indexes +includesnoexec +followsymlinks allow </directory> </virtualhost>
through serverpath able mount directory projects.loc/project1
anyway, assuming have several projects (project1, project2) want bind projects.loc/project1, projects.loc/project2, etc. utilize "alias". vhost configuration file should this:
<virtualhost *:80> servername projects.loc serveralias www.projects.loc documentroot /path/public_html errorlog /path/error_log customlog /path/access_log combined directoryindex index.html index.htm index.php index.php4 index.php5 <directory /path/public_html> options -indexes +includesnoexec +followsymlinks allow </directory> alias /project1 "/path/public_html/project1" <directory "/path/public_html/project1"> directoryindex index.html index.htm index.php index.php4 index.php5 options -indexes +includesnoexec +followsymlinks allow </directory> alias /project2 "/path/public_html/project2" <directory "/path/public_html/project2"> directoryindex index.html index.htm index.php index.php4 index.php5 options -indexes +includesnoexec +followsymlinks allow </directory> </virtualhost>
your application laying in folder /path/public_html/project1 available @ projects.loc/project1, application laying folder /path/public_html/project2 available @ projects.loc/project2 , on.
i'd rather utilize different subdomains different applications. has benefit of having own configuration files every subdomain host, makes error , access log handling easier. using alias, configuring different error , access logs more difficult, if want have them per application.
further reading: concerning alias: http://httpd.apache.org/docs/current/mod/mod_alias.html concerning serverpath: http://httpd.apache.org/docs/2.2/vhosts/examples.html#serverpath
php apache vhosts
No comments:
Post a Comment