Different virtual hosts for same website but different pages - apache

My web server directory is as follows:
var/www/html/site-part-1
var/www/html/site-part-2
In site-part-1, I have a wordpress installation, and when a person lands on my site by google organic / direct whatever when they type in the domain into addres bar it will take user to site-part-1
Currently site-part-1 is operational with the virtual host configuration directory root directory set to var/www/html/site-part-1
But I have a completely different system in site-part-2, that is built with python which I will be accessing via a link from the wordpress site.
example.com (site-part-1) will have a link, and it will take the user to my website example.com/my/directory and in /my/directory will be the contents of site-part-2
It may have worked sticking site-part-2 in the wordpress site folder but for cleanliness I put it into seperate folder
Does anyone know how I should go about setting up my apache settings so that both directories work together?

Related

dev site running on subdomain is redirecting to the main domain

I wanted to create a dev site for my main wordpress site. So I copied my wordpress files to the virtual host server and imported the database from my main site. Then I ran wp search-replace 'www.mobisium.com' 'dev.mobisium.com' (main site= 'www.mobisium.com' dev='dev.mobisium.com') to change the database url's. Then I created a dns for dev.mobisium.com using cloudflare. But now when I visit dev.mobisium.com it redirects me to the main domain mobisium.com. I don't know much about wordpress and server management. I just followed my colleague instructions.
Solutions I tried:
tried adding define('WP_HOME','http://subdomain.example.com');
define('WP_SITEURL','http://subdomain.example.com'); to wp-config
file.
adding home and site URL in wp_options in the database, but there is
no home and site URL in wp_options in the database.

Swap primary domains on GoDaddy cpanel hosting

I have two domains hosted on GoDaddy cpanel - one is the primary and the other is an Addon. Each of the two domains has a live website hosted on it (both sites developed on Wordpress). Basically I just need to swap the Addon domain to become the primary domain. What's the best way of doing this?
I have researched and there are different approaches I gathered.
1- First approach is, to swap the primary domain website files (on File Manager) to be in a sub-folder under public_html. While the Addon domain website files to be placed directly under the root of the Public_HTML folder. Also to go into the Addon Domains option in cpanel, and do something about adding the "connect" to the Addon. I didn't understand what this meant. I can see my Addon domain is in the Addon Domains list. But not sure what else I need to do there?
2- Or I saw another way is, to create subfolders for each website and specify in the .htaccess (in the public_html) the folder which you want to be the main domain (after copying some template script of .htaccess and modyfying the main domain part of the script to be your domain). Then login to the Wordpress admin and in Setting ensure the wordpress address (url) and site address (url) are pointing to the correct sub folder under the domain hosted. Apparently the purpose of this approach is not to place an entire website folders and files directly under the root of public_html, which is very messy. But to keep each website organised in its own sub folder.
So which approach is more recommended? I.e. which is the least messy?
My last question is, I already have the main domain website folders and files directly under the root of the public_html. I don't know which folders and files belong to the website, that I need to move to a subfolder. Under the public_html, I have the following folders (exclusing subfolder of other websites, which obviously belongs to the other websites). I don't which of these folder are part of the main website (to move into a sub folder) and which folders are meant to stay under the public_html:
.htpasswds
.well-known
cgi-bin
hilositelock
oldwp-content
replica
test
wp-admin
wp-content
wp-includes
wpps-tools
Please refer to the info below about the hosting info (in case it's required):
Hosting Package: Ultimate
cPanel Version: 78.0 (build 27)
Apache Version: 2.4.39
PHP Version: 5.6.40
Operating System: linux
Many thanks
Here is the solution to your question.
If you want to swap both site's data (add-on and primary domain) then first take the backup(files and databases) of both websites using some plugin (As you are using WordPress).
Then set add-on domain as primary domain.
Now primary domain will become parked domain and add this parked domain as add-on domain and install a fresh WordPress on it.
Now you can simply restore backup of both sites using the plugin you had used for backup.
For Reference you can relate to this video.

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.

Working with local and live websites. issues with subfolders in www folder

I have a live site, example.com and when i have pulled it off to a local enviroment using wampserver i am having some issues
on the live site everything works ok and if I click on a link it will resolve properly
example.com/offices
However on the localcopy because I have other sites in the www folder(as subfolders) I have to access it by
127.0.0.1:8888/example/
and when I click on the same link on the local website it will go to
127.0.0.1:8888/offices/
instead of
127.0.0.1:8888/example/offices/
And the same goes with images as the are all looking for folders in the root rather than the subfolder (www/example)
I have tried using virtual hosts and couldn't get it to work
is there a rule I can put in the htaccess or would I need a seperate install of wamp so it all resides in the www folder?

ProFtpd Homedirectory per user

I So new to linux Ubuntu and moving from windows.
The problem I have is related to ftp. This is what I am trying to do.
My websites are located in /var/www. Each website has its own root for examle
/var/www/site1
/var/www/site2
This is what I am trying to do. I would like to have a user for each site (directory) so they can access their home directory through ftp.
Looks so easy, but can't make it work. Any help or direction is appreciated.
If you want a user per site you might need to create virtual hosts in apache so that instead of the sites being located in /var/www they will be located in the user's home directory.
You can then allow users to access their home folders via ftp. These are instructions that are available on the Ubuntu site. Access them here
alternatively you can add the users as FTP users with the right permissions to the folders located under /var/www/ . Documented well in the ProFTPd website.
There's an old post here that you might still find helpful