APACHE VirtualHosts configuration for Zend project and regular sites - apache

I have such a problem:
In a local network I have a server which is called by its server_ip.
I have few sites located under /www/site_folder where index.php is located.
So whenever http://server_ip/site_folder is called index.php is called and selected site loads.
Now I put in /www/zend_site a Zend project.
It means two things:
1. index.php is located under /www/zend_site/public,
2. Zend requires rewriting rules set up so framework can understand controller/action extracted from an URL.
What I want, and can't succeed, is to have ability to call Zend project by typing http://server_ip/zend, and also to have rest of my simple sites working by calling them by http://server_ip/site_folder.
I got familiar with configuration for a Zend http://files.zend.com/help/previous-version/Zend-Server-5-Community-Edition/configuring_zend_framework.htm and tried to make use of virtual hosts by introducing new one called zend.
I see it's not possible to get such two existing options running. If zend is in virtual host and if I call only sever_ip it loads zend project instead of /www/index.php (a dummy site). If I remove virtual host after I call http://server_ip/zend it loads /www/zend/index.php instead of /www/zend/public/index.php and also site doesn't work (after I created symbolic link to proper index.php), because links are not correctly rewritten with controller/action extraction.
Or maybe I am thinking wrong about VirtualHosts idea? In server_ip/something <- something is not a domain which could be used in VirualHost in this case?....
Any idea if my configuration could work?
Regards

Related

Redirect Symfony URL

I have a Symfony3 installation on a server and I need to access the web files through the IP/game address.
So I created my "game" symfony folder with everything in it, and for now if I want to see my web content I need to add /web/app.php (or app_dev.php, nvm), which is logical.
So here is my question : How can I access my app.php (or app_dev.php) just by IP/game and not IP/game/web/app.php (or app_dev.php).
I can't configure any vhost to define a DocumentRoot so I think I have to use an htaccess but all my tests actually have failed :(
Thank you for your help and have a nice day !
The only way for this to work is always by accessing ( IP or hostname )/( app_dev.php for dev, nothing for prod )/routes
If you want to access dev environment you will need to use app_dev.php after hostname / IP. Everything after that is not related to file structure but with routing specified in configuration of Symfony application ( at least by default web server configuration which is provided on Symfony website ).

Contao is redirecting to non existend development subdirectory

Im currently trying to move a website to production that has been designed using contao. The website has been developed in a subdirectory of the current website. Now when I change the DocumentRoot to the contao directory the application automatically forwards me to the /development directory which in that situation does not exist anymore.
I did a database dump and searched it for "/development" to find the variable that is storing this information but I didn't find a match. I then did the same with the configuration files but it didn't show up any results too. How is redirecting handeled in contao?
It sounds like your pathconfig.php is wrong. After deploying/moving a Contao installation, you should always execute and log into the Install Tool under contao/install.php. This will correct your pathconfig.php.
Also make sure the RewriteBase in the .htaccess is set to the correct value (probably / in your case).

Apache routing without htaccess

I am working with a custom website built in PHP running on Apache server. The client wants to move it to a new server. I moved everything including the .htaccess file, the homepage loads fine but all the other urls like site.com/register isn't working. I'm sure this is not handled by code in the old server because I renamed everything (including .htaccess) and it still works. If I create a file like test.php in the old server, I can access it like site.com/test. It doesn't even hit the index.php file. Also, not all the urls work like this, some are loading through files in other folders.
So my question is - what are the possible ways that Apache can let user access site.com/test without the .php extension. It must not be using .htaccess. Also, we should be able to add exceptions to this so that some urls can be loaded differently.
you can achieve same thing in hosts file if you are using Linux server. you need to define same rules in hosts configuration file.

htaccess http request re-routing

Reason for Problem:
I'm working on a website and wanted to work on it without making edits to the live website. My hosting package allows for "infinite" domains. So instead of editing the live website I create a new domain, without purchasing the domain name and am trying to develop with this new domain.
Issue At Hand:
This issue is that the reference file paths don't work anymore and return 404 when trying to load the webpage. My original website directory structure looks like this
cgi-bin
config
public_html
->JSfiles
->CSSfiles
->PHPfiles
The new one is the same structure however when you open the "temporary web address" the URL looks like this
http://217.199.187.199/myTempAddress.com/"
instead of
http://myTempAddress.com/
so when my index.html file looks for /JSfiles/someJSfile.js its requesting
http://217.199.187.199/JSfiles/someJSfile.js
when it needs to be requesting
http://217.199.187.199/myTempAddress.com/JSfiles/someJSfile.js
Things I've Tried Unsuccessfully:
I would really like to fix this by redirecting with the .htaccess file in the root directory on the server. Ive tried using the following directives with no success.
Redirect /217.199.187.199/JSfiles/mustache.min.js http://217.199.187.199/myTempAddress.com/JSfiles/mustache.min.js
Redirect /JSfiles http://217.199.187.199/myTempAddress.com/JSfiles/
Redirect /JSfiles http://217.199.187.199/myTempAddress.com/
Redirect /JSfiles 217.199.187.199/myTempAddress.com/
Question:
How can I redirect the requests to the right location? I need all the the requests to be of the form http://217.199.187.199/myTempAddress.com/someDir/Somefile.ex
You need to read up a bit more on Virtual Hosting in particular name based virtual hosting.
https://httpd.apache.org/docs/current/vhosts/name-based.html
It sounds like your provider might support name based VHosts but what you're trying to do is not taking advantage of that. To do what you want ie have path that points to a different version of your site is best achieved using mod_rewrite. See this
https://httpd.apache.org/docs/2.4/rewrite/remapping.html
You need to make sure that your provided actually supports this.

How to exclude subdomain directory from main website

I've setup a VPS with apache2.
I am using cloudflare for DNS management.
Now, I have my websites's files in "var/www/website" folder. Inside that, there is another folder for forum. like "var/www/website/forum" inside which there are all forum related files.
Now, suppose I have www.website.com pointing to "var/www/website"
and I also have a subdomain forum.website.com pointing to "var/www/website/forum".
What I want to do is make the files inside "var/www/website/forum" accessible via subdomain only. I don't want users to access forum via www.website.com/forum, but I want them to access it only via "forum.website.com"
What you need to do is set up what's called a virtual host. You would put your forum at /var/www/forum and website at /var/www/website.
inside /etc/apache2/sites-available, you'll need to add an additional configuration file for that site called forum.website.com.conf.
You'll then need to create a symbolic link to /etc/apache2/sites-enabled for that file so that apache sees it. From there, you reboot the server and are good to go.
Here's some documentation:
http://httpd.apache.org/docs/2.2/vhosts/
http://httpd.apache.org/docs/2.2/vhosts/examples.html
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
This may be a bit different depending on the flavor of linux, but should be about the same. Control panels like Cpanel, Plesk and WebMan can make this process a bit easier by abstracting the configuration to a web control panel.
Hope this helps you.