I have the following setup:
The primary domain is example.com. I'm not using this site for any other purpose than managing the other (sub)sites. All the core files are hosted at this address.
I'm using subdomains (not folders), so sub1.example.com, sub2.example.com, etc. to create new instances.
I'm disallowing registrations, so I'm defaulting to another site altogether in case nothing's there at the subdomain.
The wp-config.php contains the following relevant settings:
define('WP_ALLOW_MULTISITE',true);
define('MULTISITE',true);
define('SUBDOMAIN_INSTALL',true);
define('DOMAIN_CURRENT_SITE','www.example.com');
define('PATH_CURRENT_SITE','/');
define('SITE_ID_CURRENT_SITE',1);
define('BLOG_ID_CURRENT_SITE',1);
define('NOBLOGREDIRECT','https://www.default.com');
define('COOKIE_DOMAIN', false);
if (!defined('ABSPATH'))
define('ABSPATH',dirname(__FILE__) . '/');
define('WP_CONTENT_FOLDERNAME','custom-folder');
define('WP_CONTENT_DIR',ABSPATH . WP_CONTENT_FOLDERNAME);
define('WP_SITEURL','http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_CONTENT_URL',WP_SITEURL . WP_CONTENT_FOLDERNAME);
Now, my question is: assuming I've created a subdomain named "sub1.example.com"
for the new domain "landing-page1.com", what addresses should I ideally use for the Siteurl and Home fields in site-settings.php at the sub1.example.com instance?
Because currently I'm running into an issue where I've entered "http://www.landing-page1.com" for both fields, and "http://landing-page1.com" now consistently reverts to https://www.default.com, while "http://www.landing-page1.com" works as intended (showing the content for "http://sub1.example.com".
Ended up using 3rd party plugin: https://github.com/humanmade/Mercator to create a new alias. Seems superfluous, given WP's built-in domain mapping, but it does the trick.
Related
I am looking for a WP php rule to always serve any webpage via the desired host without adding a redirect rule which is not an option in this case. see below.
We have our main site on one server and a WordPress installed on another server. We use cloudflare workers to serve the blogs content (blog.domain) via a subdirectory of the main server (domain.com/blog).
To avoid some issues on the admin side of WP we had to modify the wp-config.php to specify the correct host which would be the main domain/blog
$_SERVER['REQUEST_URI'] = '/blog' . $_SERVER['REQUEST_URI'];
$_SERVER['SCRIPT_NAME'] = '/blog' . $_SERVER['SCRIPT_NAME'];
$_SERVER['PHP_SELF'] = '/blog' . $_SERVER['PHP_SELF'];
$_SERVER['HTTP_HOST'] = 'www.domain.com';
source: https://core.trac.wordpress.org/ticket/36201#comment:17
What I noticed afterward is that (1) WP admin will always redirect the subdomain to the desired host, so if I go to the wp admin panel via the original subdomain it will redirect to the main-domain/blog/wp-admin.
( 2) Even when I hit a front end URL and I am logged in to the WP admin the same will happen, the host will be replaced.
(3) if I am not logged in to the admin panel but I am using a URL with a query parameter such as
https://sub.domain.com/?page_id=3
it will redirect to the desired host with the clean URL.
My question is how can I get WP to always redirect to the desired host? Using a simple redirect rule in PHP or apache/Nginx will result in an infinite loop (since the sub-directory is relying on the subdomain for the content)
I want to make a multi-lingual site. Firstly I created a wordpress website. Then I installed wordpress on another site and changed the table prefix of the second site to the one of the first site. So now these sites are sharing the same database and their addresses are http://academy2.hollywoodpress.biz and http://en.hollywoodpress.biz . However, http://en.hollywoodpress.biz is not working but http://en.hollywoodpress.biz/wp-admin is working. How can I fix this problem?
Why you don't use WordPress multi sites feature.
http://codex.wordpress.org/Create_A_Network
You can make WordPress use somewhat dynamic request hostnames using the following in your wp-config.php
define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);
This way WP will set the site and home URL addresses properly for each domain which is used to request a WordPress page. I think wp-admin will use the value which is determined in the wp_options table (home and siteurl rows).
If you need to display different content on different domains altogether, then you should consider either multisite or two separate WP installations.
If you're only looking to translate content and are OK with either subdomains (en, de, es, etc.) or subfolders (en, de, es, etc.), consider using localization plugin such as Polylang or WPML.
I could solve the problem. The problem was that I used subdomains for separating domains and they didn't work for WPML. I used a domain and I could finally separate domains.
I have a question. I am trying to set up two domains under one wordpress instance.
For instance, I have a wordpress site on www.site1.com
I have another domain called www.site2.com. Now, I want to run the same wordpress site that is under www.site1.com on www.site2.com
I tried using the wordpress domain mu mapping plugin
http://wordpress.org/plugins/wordpress-mu-domain-mapping/installation/
But it only allows me subdomains or directories of www.site1.com
Can anyone help?
Add
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] );
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] );
to wp-config.php.
If you meant pointing 2 or more domain names to a single wordpress install, answer is yes you can but it won't work. Wordpress is designed only to host one domain name, if you point another domain name to your wordpress, it will return 404. The other way around to do this is redirect your other domain names to your main domain name (i.e. redirect website2.com to website1.com)
If you meant pointing 2 or more domain names to a Wordpress Multi site install, here's an article that will help you setting up domain mapping in your Wordpress multisite: https://rtcamp.com/wordpress-nginx/tutorials/multisite/domain-mappinng/
We need to set WordPress Multisite Network to make it work. I have successfully set my wordpress v4.1 installation to work for multiple sites and multiple domains by following this and this.
Please note that you will have to make sure editing to php files correctly otherwise that will completely crash your site if you make a mistake. Moreover a correct setting of htaccess is also important.
I'm using XAMPP to learn wordpress these days.I've established a simple site.After opening 80 port in my router,I can visit my site like this:
ExternalIP/wordpress
The problem is:I can ONLY open my index.php.I notice that the links in index.php all begin with "localhost/".I know I have to do something to modify it to my actual IP address,but I cannot figure out how to do it.What am I supposed to do?
Best regards.
Sometimes it is easier to temporarily add your siteurl and home url to the config file, rather than updating the DB. That way when you go live you just remove the lines from your config.
Add the following lines to your wp-config.php file after line 64 where it says define('WPLANG', '');
define('WP_SITEURL', 'http://YOUR_LOCAL_IP');
define('WP_HOME', 'http://YOUR_LOCAL_IP');
If you have WP in a sub-directory add that directory to the WP_SITEURL var only, for example:
define('WP_SITEURL', 'http://YOUR_LOCAL_IP/wordpress');
define('WP_HOME', 'http://YOUR_LOCAL_IP');
Replace YOUR_LOCAL_IP with your actual host machine IP, such as http://192.168.0.1.
If you are not developing locally, and only accessing remotely, you can use YOUR_EXTERNAL_IP in place of the local one.
Finally, navigate to WP Admin -> Settings -> Permalinks and click Save. This will reset WP to use your new value for links.
If you have any hardcoded links or images in Posts or Pages, you'll have to manually update the URLs for those.
Is there a way to clone a Wordpress website but keep all the plugin settings etc for a completely new website?
I've turned Wordpress into a cms with the help of some plugins and some of my own tweaks. I want to roll this out as the cms I use for every website I create so therefore don't want to have to install all the plugins each time and adjust their settings.
I don't want to copy the content of the site just the plugins.
It's not as simple as ftp'ing all the files down then up to some new hosting space.
How can I go about cloning the website?
Would wordpress multisite work for this? I know it does sub domains etc but can I use multisite over several different domains?
A backup of the database, and a copy of the files in the wordpress directories. On the new site, you would need to have changed the URL in the config database, which if you backup the database you could change in the text file you backed up to, before uploading to the new site.
Also http://codex.wordpress.org/Changing_The_Site_URL suggests you could set a setting and any chances will be auto reflected when you load it somewhere else.
Have you checked if the copy wasn't corrupted?
Please check if the /home/biologic/public_html/wp-includes/load.php file is there.
Or maybe the ABSPATH above is wrong... if it is, then check if you have this on your wp-config.php file:
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
if it is there, replace dirname(__FILE__) . '/' with the actual absolute path, hardcoding it.
I've figured out the process:
Ftp down the files from your existing site.
Change the wp_config to the new details of the database.
Ftp up the files to the new site.
Download the database of the old site.
Import into the database of the new site. Change the wp_options siteurl to the new site address.
Login to the admin and change the site address to the new domain.
Update the permalinks.
The site is cloned successfully.