Change Domain VirtualHost paths in Plesk (Apache) - apache

I have a domain that'll be using Zend Framework and I need to modify the documentroot for this particular domain to resolve to Zend's path.
Anyone know how to update the virtualhost on a particular domain?

Typically, you don't have to modify the document root.
Put your application files one level above your document root, and put the contents of the zend public folder in whatever your document root is (e.g. public_html or htdocs).

Related

Compute Engine Custom domain accessibility

I have a Google Compute Engine instance(installed apache, php, mysql etc.) and a custom domain name. I can do add my Custom Domain to my Google Compute Engine.
Lets my domain name be www.try.com .
my instance's "www" folder;
--->try
--->somethingelse2
--->somethingelse3
..
How can I set "www.try.com" access to only "try" folder? Thanks.
In deciding what file to serve for a given request, httpd's default behavior is to take the URL-Path for the request (the part of the URL following the hostname and port) and add it to the end of the DocumentRoot specified in your configuration files. Therefore, the files and directories underneath the DocumentRoot make up the basic document tree which will be visible from the web.
If a directory is requested (i.e. a path ending with /), the file served from that directory is defined by the DirectoryIndex directive. For example, if DocumentRoot were set as above, and you were to set:
DirectoryIndex index.html index.php
You only need to modify the path in the Directory index.
You can find more information here

Apache URI path recognition / mapping?

I have a website for all intents and purposes is called.
www.foobar.com
Which in my server path is /var/www/
I tried to create a new folder in /var/ called "analytics", with the hope that if I typed www.foobar.com/analytics I could access that folder.
However that does not work because it is actually looking for /var/www/analytics instead of /var/analytics
So how can I have multiple directories mapped to a URI?
For phpmyadmin I can access www.foobar.com/phpmyadmin with the phpadmin folder is in a completely different directory. So it must be possible.
However I tried googling but could not find any answers so I guess I do not have the right description of what this functionality is on Apache webservers.
Any help would be appreciated.
You have to create virtual directories in Apache.
If you are using Apache2, then can you go to the directories
/etc/apache2/sites-available and /etc/apache2/sites-enabled.
You have probably only the default virtual directory enabled.
You can make a copy of a virtual directory in the map /sites-available.
A virtual directory starts with specifying what the root directory is.
Then can you use the commands a2ensite and a2dissite in order to enable or disable the virtual directories respectively.
After a change in enabled/disabled virtual directories do you need to restart/reload the apache server.
If you use .htaccess file, do not forget to set AllowAccess (in the tag Directory) to at least FileInfo or .htaccess will be ignored.
If you want to make those directories different hosts, then can you make aliases in /etc/hosts.
On my home computer have I aliases for the ip addresses 27.0.0.1 and 27.0.1.1.
That gives me the possibility to have two different sites at the same time.

Need of vhost for zend application

If running any zend application it is recommended to ceate the vhost.
Why is it so?
Although the public part form the url can be removed by copying the index.php and .htaccess file to root of project directory.
Well... yes, technically can just copy index.php and .htaccess to the root of the project directory. However, by doing that you will expose all of your application files to the public.
For example, someone could try to access your config file like this: http://yourhost/yourproject/application/configs/config.ini
This will actually display the content of the config file (which might include sensitive data like your database configuration) unless you explicitly configure something in your .htaccess to prevent this.
When using a vhost with the DocumentRoot set to the public dir, that means that no file outside the public directory will be accessible from an URL. And since you should normally only have the index.php file in there, you ensure that your application is always accessed from that starting point.

htaccess restrict folder access based on domain

I have a web setup where there are multiple sites under one directory... and one media folder containing images for each site...
www.domain1.com/media/domain1.com/
www.domain2.com/media/domain2.com/
As you can see domain1.com's media can be accessed from domain2 e.g. www.domain2.com/media/domain1.com/
and vice versa...
I want to restrict domain1 to access /media/domain2.com/ folder can it be done via htaccess file?
my idea was to somehow read the domain name and match it with the directory its trying to access...
or
alternatively can redirect all requests in media folder to a php script that can do the matching...?
Use VirtualHost for each domain and specify DocumentRoot for them, it will also remove the /media/domainN/ from URL.
If you want to perserve the document root for some reason, try using this in each VirtualHost directive:
<Directory "full/path/to/media/domain1.com">
deny from all
</Directory>
and vice-versa for domain2.

Apache symlink to a folder outside of web root

Here is the folder layout.
/outside is not normally accessible anywhere on example.com
/public_html is the folder for http://example.com
How can I use Apache's htaccess to make the url http://example.com/outside/ to show content from the folder /outside?
Thanks!
How can I use Apache's htaccess to make the url http://example.com/outside/ to show content from the folder /outside?
You can't. As far as I have found out, Apache prevents directives in .htaccess files linking to locations outside the current web root.
You would have to do this in the central configuration:
Alias /outside /path/to/your/outside
You may be luckier with a symlink if you can turn FollowSymLinks on.