Sub-domain as sub-directory in URL - wordpress

We need solution for our new server, we have one main domain e.g. example.com and its hosted on VPS this website is in ASP.Net with blog e.g. example.com/blog , The blog is in sub-directory and using Wordpress. We got new server and we want to move our blog on new VPS so we created sub-domain on main domain e.g. blog.example.com and change the A Record in control panel and blog.example.com is working fine, but we want to show URL like this example.com/blog/ is there a any way we can show sub-domain as a sub-directory ? The main website will remain host on main server we only need to work with sub-domain. So it shows all links like, example.com/blog/post-name/

Try this in your .htaccess:
RewriteEngine On
RewriteRule ^blog/(.*) http://blog.example.com/$1 [P,L]
It uses mod_proxy (and will fail if it's not available) to reverse proxy the traffic beneath /blog/. Obviously, if you have a lot of traffic or bad connection between the two servers, you will want something that does cache, but usually works quite good.
You will probably have to set
define('WP_HOME', 'http://example.com/blog');
define('WP_SITEURL', 'http://example.com/blog');
in your wp-config.php so the internal links point to the URL you want them to work as.

Related

Plesk WordPress Multisite Install with Non-www Domains

I'm trying to do something that's pretty straight-forward in cPanel, but I wish to use Plesk instead. I'd like to create a WordPress multi-site install and point various domains and sub-domains to it. Here are examples:
www.mymaindomain.com
test.mymaindomain.com
www.newdomain.com
multi.anotherdomain.com
In cPanel, it's pretty painless:
Create a WordPress multi-site install under www.mymaindomain.com
Point the domains to cPanel's IP address in DNS
Add sub-domains (e.g. test.mymaindomain.com) and addon domains (e.g. multi.anotherdomain.com) and point them to the folder of the install.
Within WordPress multi-site, add the new sites, 1 for each domain/subdomain pointed.
It's similar in Plesk. However, the complication comes when trying to point non-www domains that are not sub-domains of the main domain (e.g. multi.anotherdomain.com) to the site. Plesk doesn't have 'Addon' domains like cPanel. Instead it has 'Domain Aliases' where it forces you to use a www domain.
I'm not finding any good simple instructions for this in Plesk. Are there any?
If you know the differences between cPanel and Plesk, the answer is straight-forward. Basically, if you want to point a subdomain to a subscription (i.e. one group of domains) for a WordPress multi-site, then even if the main domain isn't pointing to the server, you still need to add it first, then create the subdomain after that and point it to the httpdocs folder of the main subscription domain.
Although it is an old question, I will answer this because the situation has not changed since then.
cPanel's "add-on domain" is the same thing with "alias domain" in Plesk, however, Plesk does not support adding an alias for subdomains. See this KB article: https://www.plesk.com/kb/support/how-to-add-an-alias-for-subdomain-in-plesk-for-linux/
In the same article they also provide two work arounds one of which involves only adding a top level domain as an alias to a subdomain. The second work around however doesn't have this limitation. You can add extra directives for Apache and nginx to Plesk configuration of that domain like;
For Apache:
ServerAlias subdomain.example.com
ServerAlias example.com
ServerAlias www.example.com
For nginx:
server_name subdomain.example.com
server_name example.com
server_name www.example.com
If you are using nginx as a proxy to Apache, then you will most probably need to do both. The downside is that you won't see anything about these aliases in any place of Plesk and nothing is configurable about them from the GUI.

Routing for Wordpress Multisite with both subdomain and subdirectory

New to WordPress but finally got close to what i want. What I wanted was to use multisite with both sub domains and sub directories.
What i did:
- I setup wordpress multisite with subdomain option.
- I setup my domainname to allow wildcard subdomains
- I use the standard htaccess file for subdirectories (this fixed a css issue to diaplay sites with both subdomains and subdir correctly)
- After I create a new website I go to edit and add a subdirectorie to the url
The result:
The above steps allowed me to create websites like the list below:
- domain.com
- sub1.domain.com
- sub1.domain.com/en
- domain.com/en
- ...
The problem:
All the websites display correctly, but the admin url for urls that have both sub domain and sub directories doesn't seem to work (eg. "sub1.domain.com/en/wp-admin/").
The solution?:
I think it can easily be fixed in the htaccess, mainly with changes to the standard line below:
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
Does anybody know how to rewrite the above line so the wp-admin can be accessed by domains that have both subdomains and subdirectories? Keep in mind that it also has to work for domains that only have a sub domain or sub directory.
since the above might not be possible I ended up working with the plugin WP Multi Network https://nl-be.wordpress.org/plugins/wp-multi-network/ .
Now I can create a network per subdomain which is also a multisite then i can create subdirectory sites per subdomain. All users are shared across all sites/networks.

"www" issue on WordPress site

I just starting with WordPress, I am using Digital Ocean and a domain. I went to WordPress setting and added "www" to website name as it was naked before, the site stopped working and shows nothing now. How to fix this?
After changing the site URL and home URL to www, you need to add ServerName as www.yourdomainname.com
Assuming you have a single host.
sudo nano /etc/apache2/sites-available/000-default.conf
Change the file as below.
ServerName www.yourdomain.com
ServerAlias yourdomain.com
Now you need to have 2 A records with hostnames # and www pointing to your IP in your DNS.
Hope this will resolve the issue.
Who did you buy your domain through? You should go to your settings there and change your DNS settings to do a www redirect for you. Then just make sure the box is listening for the site name with the www prefix.
Usually changing the domain name for a site isn't quite this simple, although adding in 'www' shouldn't cause too much grief I'd think.
However, to get things back up and running, you'll want to get into your site's database (via PHPMyAdmin or something like that) and open the wp_options table. In the first page of that table, you should see an entry for site_url, which you can edit and remove the 'www'. That should at least get you back up and running. Then we can sort out what the other issue is with the subdomain.

I need to repoint a Domain on a Names host to another server that runs my WordPress site?

I have a Domain host (JustHosts.com) that host my domain name:
mydomain.com
I have another server with a WordPress site on it which is accessed directly as:
mywordpress.com/wpsite1
I want this to be accessed via mydomain.com, so:
mydomain.com -> mywordpress.com/wpsite1
The URL should stay as mydomain.com, not go back to mywordpress.com/wpsite1.
I can add the following types of records:
A
CNAME
MX
TXT
SRV
AAAA
What should I do on my domain host to make this change?
Many thanks.
I could solve this in particular condition where we use subdomain to pointing to the WordPress site and the Wordpress site itself is installed on a host provider that is using cPanel.
Formerly I simply set CName on subdomain blog.mydomain.com to the subdomain where my Wordpress site is installed. Unfortunately this pointing was resulting a redirection like this:
http://blog.mydomain.com/cgi-sys/defaultwebpage.cgi
Searching for a solutiom then I found this documentation:
https://wordpress.org/plugins/wordpress-mu-domain-mapping/installation/
It is actually a documentation for a plugin to map any blog/site on a WordPressMU or WordPress 3.X network to an external domain. I didn't install the plugins I just marked that for cPanell users we need to put the mydomain.com as a parked domain in cPanel where the Wordpress site is installed.
So with the cPanel I uninstalled my WordPress and rearrange the installation step as below:
1. Put mydomain.com as a parked domain
2. Re install WordPress using blog.mydomain.com
Viola! The blog.mydomain.com is running the WordPress perfectly and stay in blog.mydomain.com without any error or redirection to other domain.

Hosting a wordpress blog on a server with other web sites

I have a wordpress installation on its own folder, on my server that hosts another site (non-wp) to. I want to keep the wp installation to its own sudirectory, but change the url to point directly to the blog (to get rid of /wp in the url).
Is it possible?
How does the index.php have to be configured to correctly point to both sites hosted?
You should set the subdomain in something like your cPanel with the web hosting.
Example:
I want to have: blog.domain.com and www.domain.com
www.domain.com is set by default.
In your hosting settings, you will need to create the blog sub-domain and have it point directly to another directory.

Resources