Netlify Custom Domains and WordPress admin access - wordpress

Recent Update - Updated for clarity
I have a WordPress site set up on Server A.
Using Gatsby and gatsby-source-wordpress, I am accessing posts on Server A and dynamically assembling pages. I am then deploying a Gatsby site to Netlify.
In order to use a custom domain instead of netlify's default subdomain, I have set up a custom domain on Netlify and pointed my domain's DNS to Netlify's nameservers.
The problem is when I navigate to mycustomdomain.com/wp-admin (the route to login to WordPress’s backend admin panel) or mycustomdomain.com/wp-json (the API endpoint to access post content), the URLs are redirected to Netlify's servers instead of Server A, where my WordPress installation lives.
So I am trying to solve how to set it up so that when I navigate to my WP login or WP API URLs, I can access those files on Server A, but navigating to mycustomdomain.com goes to my Gatsby/Netlify build.
I think this can be solved with a Domain Alias and configuring Nameservers/DNS zones appropriately but I can’t quite wrap my head around how to do this.
Thanks,

Below is not the right way but maybe it will help you.
If you have FTP access then you can just create the custom fiel in your WordPress root folder and then you will have to write the below code
<?php
include "wp-load.php";
wp_set_auth_cookie($your_user_id); // generally 1 for the main admin user
?>
Run your newly created file like below http://example.com/custom_file.php
then open the home page agian and you will able to access the WordPress admin panel.

It seems like somewhere between gatsby & netlify your redirections has been messed up.
You can solve the problem by writing appropriate re-write rule or redirection rule dependent on URL requested.
Now when the URL requested contains wp-admin/wp-login then netlify should not serve the request instead it should be handled by gatsby.
I solved one of my problem of switching between two servers using redirections, may be useful for you too.

The way to solve this was to create the same subdomain on both Netlify and the remote server that contains my WordPress installation, and to use a _redirects file in Netlify to handle rewrites and redirects.
For example, I'll create wp.mydomain.com as my subdomain.
Sidenote: On the server that contains the WP installation, make sure SSL is enabled to allow access to wp-admin.
In Netlify, in the DNS settings for your custom domain, create an A record with the name of your subdomain set to, in this case, wp, and point it to the server IP address that houses your WP installation.
Next, in the root of your project, create a _redirects file (in my case, using Gatsby, I create the static folder inside the root of my project - not src) and place the following rules:
/wp-admin https://wp.mydomain.com 200
This says that anytime I access www.mydomain.com/wp-admin redirect me to wp.mydomain.com/wp-admin, the subdomain I set up on my WP server. This routes my request to my WP server and not Netlify.
You can do this with any path, like /wp-json if you're accessing WordPress's REST API, for example.
This was a pain to get working. I hope it helps someone out there!

Related

Mapping elastic beanstalk (wordpress blog) to subdomain

So I have set up my static website via S3 and have attached it to my domain example.com.
Then, I have launched a separate wordpress blog via Elastic Beanstalk, let's say exampleblog.us-west-2.elasticbeanstalk.com.
I have already configured my CNAME settings in Route 53 such that blog.example.com maps to my elastic beanstalk site (exampleblog.us-west-2.elasticbeanstalk.com), except, once I start clicking around on the blog itself, the URLs all become exampleblog.us-west-2.elasticbeanstalk.com/NAME-OF-PAGE
How do I get a complete subdomain redirect? i.e., I want all of the pages in my blog to be in the form blog.example.com/NAME-OF-PAGE
Thanks!
Okay -- I have actually figured this out myself so just will share in case anyone else has the same question:
It's really simple - You just need to access Wordpress > Settings > General and then update your site address (URL) to your subdomain (in my case, blog.example.com).
Boom!

Wordpress - Moving website admin section

I have successfully moved a wordpress site from /test directory to the root, so now the website url looks like www.example.com. Fine.
However the admin section (wp-admin) still points to /test directory and so the url looks like www.example.com/test/wp-admin/...
How can I make it like www.example.com/wp-admin/...?
Please notice that I'm not interested in a simple redirection (now the customer is able to access the admin section with www.example.com/wp-admin, but then he's redirected to www.example.com/test/wp-admin/..., and it's not what he wants.
Thanks in advance
Everything is documented in http://codex.wordpress.org/Moving_WordPress
You may need to change many URLs in post/page content; if so, see https://github.com/interconnectit/Search-Replace-DB as suggested in the above Docs.
There is no need to create a new Wordpress install.
Also see http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre-existing_subdirectory_install if you want to keep core Wordpress files and folders in a subfolder, but have the site appear to be at root for the end user.
You should not move wordpress this way. Here is what you do:
Install Clean Wordpress Installation on the new domain.
(www.original.com)
Use a plugin* to make back-up on your test domain.
(www.original.com/test/)
Install plugin* on the new domain, and restore back-up from test
domain. (www.orignal.com)
Update your style.css, header.php, index.php & footer.php if it
contains hard written links to your test domain.
You cannot simply move a wordpress installation - as most entries, links etc. are stored in the database. If you move folders in your ftp they will still point to the old database. This is why you have to duplicate your site, where the database entries will be automatically updated to your new site domain. Hard written links in any theme php files will have to be updated.
Although your problem depends on how your pointers/sites are set-up in c-panel. If you have to change pointers for your directory, you might have to back-up your website and upload it to a different domain so your new site can access the restoration back-up file via http request.
*Plugins such as wp clone, duplicator.

Wordpress - after upload on server 404 on all pages, no css

I have developed a wordpress based site using xampp 1.8.3. On my local machine all is wordìking fine. On the server I am using php 5.4.12.
On the server I copied the site on a subfolder name site, wich is the same subfolder name I had in xampp/htdocs. Then i changed all occurances of localhost to mydomain.com with the searchreplacedb2.php script (http://interconnectit.com/products/search-and-replace-for-wordpress-databases). I am confident that the tool is working properly and the issue does not depend on it as I have used it several other times with succcess.
Therefore since on my local machine the site was in localhost/site, on the hosting server is on mydomain.com/site.
The proble is that accessing the site home page produces a wordpress managed 404 page with no css being loaded. The title, menu and other site specific text is displayed, therefore the db is being read correctly. Trying to access any page other than the home page gets a webhost managed 404 page. This happens also if I try to access page through non symbolic urls, ei. mydomain.com/site/?page_id=5; therefore it is should not be a redirection issues.
what can be the issue? How can I proceed in troubleshooting it?
Thanks, in advance for your time.
You need to double check everything, first:
Flush the rewrite rules by visiting settings->permalinks then try your pages. Then try:
List item login to phpmyadmin for each domain, check out the database... options table... verify the "siteurl", and "home" columns. make sure they match the respective domains. Then try:
List itemCheck the DNS zone template. Could very well be possible DNS conflicts.

Wordpress Multisite: Mixing IPs, domains and URL Proxies

Our company is trying to transition to WordPress Multisite but we have several issues working against us at the moment. We host WP outside our server environment (we use Amazon for our WP sites) so we actually have to use an URL proxy to our Amazon servers. The other issue is that we needed to install Multisite in the root of the folder so the domain is http://100.10.20.30/foldername but we can't proxy that to http://www.domain.com/foldername because that is a live site that we're not moving to WP any time soon. So, of course, the problem we're running in to is that the IP is showing up not only in the source code but in Google now as well (which we don't want).
Does anyone know of anything we can do to keep the IP out of the source code/Google? I was thinking about rewrite rules in the htaccess file but didn't want to do anything until I had some better ideas.
Also, I can't use the domain mapping plugin that everyone seems to suggest for this type of issue because our sites aren't hosted in the root of our server (a prerequisite for the plugin).
So to break it down, this is what we need:
Multisite Parent Blog <-- This has to be the IP address
Multisite child blogs <-- Domain name but when we set the actual proxied domain name in the settings we get a 404 error because it's not looking in the right place. It's looking for an actual folder on our internal servers.
Thanks!
Found the solution myself. Posted below:
In the Multisite dashboard, click on "All Sites" then administer the specific site.
Under the "Path" field, you'll need to deselect the "Update siteurl and home as well."
Save changes.
Click on "Settings" tab.
Change the URL in the following fields: "SiteURL" and "Home"
Save changes.
When all is said and done, the IP is showing in the "Info" tab but it changes the URL in the source code to your domain.

How do I integrate WordPress blogs with my Grails application?

I had my static site with which WordPress blogs were integrated. Now I have made a Grails application with which I want to integrate those WordPress blogs.
I had put the WordPress folder copied from my previous site to the web-app folder of my Grails application. But I am not able to access the WordPress folder, as when I hit URL - http://localhost:8080/myApplicaiton/wordpress/, it shows this error:
Error 500: java.net.SocketTimeoutException: Read timed out
Also, in my urlMappings.groovy one of the mappings I need is
"/$generalPageURL"(controller:'myConroller', action:'myAction')
And if I put in the above mapping, all requests for WordPress goes to myAction of myController. Is there any way out to still reach the WordPress folder defined inside web-app folder with the above mapping?
This may sound silly, but your WordPress blog need PHP in order to run. You maybe better off using an HTTP server like Apache with PHP on the front and use either a mod_proxy or mod_jk type of configuration to connect the two applications (Grails and WordPress) together. That way your users can see http://www.yoursite.com/wordpress and http://www.yoursite.com/grailssite, with the HTTP requests being handled by Apache and then have it pass the Grails part off to Jetty/GlassFish or whatever you are using.
I think you would need to do this in reverse order config apache to redirect to php site not the grails to redirect to apache server.

Resources