Wordpress returns IP address instead of domain - wordpress

This was working for years until I did something that has now jacked this up....
Searching on this topic landed me in several places that basically said: You need to check the Wordpress URL and the site URL in the general settings in Wordpress. I have done so and they are both: http://www.petesworkshop.com/blog_wp . Yet, when I hit that URL I am redirected to my internal IP and get a error http://10.0.10.206/blog_wp (yep, that would be wrong!
Interestingly enough, I can get to the admin page just fine and it is just a subfolder of blog_wp. So, somehow things directed to /blog_wp return the IP but everything else is OK. Wierd.
Wordpress sits behind an Apache proxy which has this directive for the virtual host:
<VirtualHost *:80>
ServerName www.petesworkshop.com
ServerAlias petesworkshop.com
ProxyPass / http://10.0.10.206:5080/
ProxyPassReverse / http://10.0.10.206:5080/
</VirtualHost>
The server running the website behind the proxy has this:
DocumentRoot "/www/petes/htdocs/petesworkshop/"
ServerName www.petesworkshop.com
ServerAlias petesworkshop.com
DirectoryIndex index.html index.php index.htm
ErrorLog logs/petesworkshop.log
Options FollowSymLinks
Alias /blog_wp /www/petes/htdocs/petesworkshop/blog_wp
<Directory /www/petes/htdocs/petesworkshop/blog_wp >
Order Allow,Deny
Allow From all
</Directory>
<Directory /www/petes/htdocs/petesworkshop >
Order Allow,Deny
Allow From all
</Directory>
I am not sure how I jacked this up...it is probably something that I did to the Apache configuration but I can't be sure since everything else behind the proxy works fine. I even tried adding specific ProxyPass entries for /blog_wp but that didn't make any difference.
Stumped...

Check your wp-config.php for correct urls
like below
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

This one turned out to be an Apache proxy issue. What I needed was to add 'ProxyPreserveHost On' to the configuration, which I thought I had in there originally but I either removed it in an edit or had it placed in the wrong virtual host. In any case, adding the ProxyPreserveHost On flag, took care of the issue. Not sure why other entries in the same virtual host DID work without it but I am not going to worry about it.

I had a similar problem some time ago, whenever I wrote my domain in the browser it was solved correctly but my domain name was changed by the IP, after much research it turned out that the problem was in the hosting, not in the server, so which only change the configuration of my domain in GoDaddy since I was only doing a redirection but the correct thing was to create an A record that points to # (which represents your domain name) and everything started to work correctly. I hope it's help

Related

How to prevent WordPress setup in 'blog' subdomain, redirecting to 'www' when trying to finish Installation

I have a main site http://www.example.com that's written in another language (Ruby/Rails). I want a wordpress blog installed in http://blog.example.com. I have control over the server and DNS.
I have created the necessary CNAME record for the 'blog' subdomain. But after setting up apache and restarting it, when I visit http://blog.example.com, for the final installation steps, I'm redirected to http://www.example.com/wp-admin/install.php.
Also now when I try to visit the main site http://www.example.com, I'm being redirected to the above wordpress install page.
How can I make it work like this: the blog should only reside in blog.example.com path, and the main site should be accessible via http://www.example.com.
Removing the www subdomain is not an option as it's been like that for awhile for the main site. It might be ok, if somehow a redirect can be setup from www to non-www url, though I'm not aware how to set it up.
Please suggest.
Here's the main site's apache conf:
<VirtualHost *:80>
ProxyPreserveHost On
ServerAdmin webmaster#localhost
ServerName http://www.example.com
ServerAlias example.com
DocumentRoot /home/apps/example/current/public
<Directory /home/apps/example/current/public>
AllowOverride all
Options -MultiViews
</Directory>
#RewriteEngine On
#Redirect / http://example.com/
</VirtualHost>
Here's the apache conf for the wordpress under 'blog' subdomain:
<VirtualHost *:80>
ServerName blog.example.com
ServerAlias blog.example.com
ServerAdmin webmaster#localhost
DocumentRoot /home/apps/example_blog/wordpress_blog
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/apps/example_blog/wordpress_blog>
AllowOverride All
</Directory>
</VirtualHost>
WordPress has domain references in the database and the code which will throw your permalinks off and cause bad redirects. These renegade URLs should appear as 404's on your root domain (example.com). If not I'd double check the root domain with the sub domain removed from the vhosts.
I don't see any issues with your current vhost configuration. I would also try testing the domains in isolation if you suspect its vhost related. I suspect its a WordPress site url issue.
Assuming the database records are incorrect.
Log into phpMyAdmin or other database manager.
Select your WP database.
Go into the wp_options table (wp_ prefix may be different).
Look for the record's with option name = "siteurl" & "home".
Edit these records to reflect your new domain name.
Here's the WordPress documentation on how to switch a sites urls schema.
Document
Your problem is likely deep in various DB references throughout your WP project. I've run into this problem deploying WP before. You'll need to edit the DB directly to fix the issues.
Export your WordPress DB with phpMyAdmin or SequelPro (something that gets you a clean .sql file)
Use a text editor like Sublime or Atom, search for "www.example.com" and replace all with "blog.example.com" then save.
Upload DB to prod location and you should see these errors go away.
This should not happen if your virtual host is configured correctly
but still as your tables are not created so you can only do one try with this step :
you can add in your wp-config.php file the following parameter
define('wp_site_domain', 'blog.example.com');
This will force the wordpress to follow blog.example.com

Local wordpress website through two PCs

I have already installed XAMPP in my local computer and also a wordpress website. Is there any way to see the default page of my wordpress website (only the page, not the administration) from an another PC in the same network (home network)?
Having a URL such as http://example.dev/index.php instead of http://localhost/example/index.php is much clearer, works better with some website "extensions" involving paths and routing, and stored passwords are much easier to manage in browsers. Let's face it, it's just better all around.
EDIT: Since you've asked for external access (two PCs), I've changed this from my original configuration example, which is isolated from access except through the loopback interface. This example assumes your LAN is properly secured. Either firewall your LAN or change configuration as noted in commented portions of the configuration file to be more specific about access.
There are a few steps to get it working, but once you get used to the two files you'll work with, it's quite easy to set up a new project later.
Activate Modules in httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule log_config_module modules/mod_log_config.so
Activate Virtual Host Settings in httpd.conf
#Listen 12.34.56.78:80
Listen 80
<VirtualHost *:80>
Comment out directory information
#DocumentRoot "E:/xampp/htdocs"
#<Directory "E:/xampp/htdocs">
...
Be sure to close the VirtualHost directive before the file includes:
</VirtualHost>
Configure Virtual Hosts Configuration File
After making the previous changes to Apache’s base-level conf file, you can work with the vhost extra conf file (%xampp%/apache/conf/extra/httpd-vhosts.conf).
<VirtualHost *:80>
ServerAdmin webmaster#myexamplesite.dev
DocumentRoot "C:\Users\JHaas\Documents\Projects\MyExampleSite"
ServerName myexamplesite.dev
ServerAlias myexamplesite.dev
ErrorLog "logs/myexamplesite.dev-error.log"
CustomLog "logs/myexamplesite.dev-access.log" common
<Directory "C:\Users\JHaas\Documents\Projects\MyExampleSite">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from none
Allow from all
#Allows a specific IP to access your VHost
#Allow from 10.0.0.24
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
Editing /etc/hosts
Finally, you edit the /etc/hosts file. This file is helps your system bypass the need for a DNS query, allowing you to create your own TLD (top-level domain) suffix such as *.dev, or anything that isn’t going to collide with current new top-level domain suffixes (*.me used to be quite popular until that suffix itself became a TLD suffix).
The localhost entry is not always required (depending on platform), and from my experience has actually caused problems if uncommented, so leave it commented out if it is already. If you see that localhost is not commented out (again, depending on your platform), be sure to leave it so. Changing the localhost entry from default can cause issues for many network services if it’s changed.
Also note that chrome has an issue with using *.local, so it’s probably best to avoid using this TLD suffix.
Host computer:
127.0.0.1 localhost
127.0.0.1 myexamplesite.dev
On the other computer, modify the /etc/hosts file to have an entry for your computer.
10.0.0.27 myexamplesite.dev
You can test your changes to the configuration files via command line using apache/bin/httpd.exe -t. This runs a syntax check on your configuration files.
Lets assume the ip of the pc running xampp is 192.168.0.198 and you are using the standard xampp setting regarding ports and the wordpress sites folder (testproject) sits in the xampp htdocs folder then you could access the site within the local network via:
http://192.168.0.198:8888/testproject/
Hope that helps. Best regards Ralf

Best solution for TLD plus a subdomain of that TLD on a WordPress Multisite

Old hand with WordPress and a lot of multi-site experience here. But I am chewing on best way to route a subdomain of a TLD already domain mapped on the MS installation.
EXAMPLE: TLD is A-Recorded to the WP multi-site via IP and correctly resolves. Say it is MAPASITE.com and that is correctly finding the right blog. Now if I want to next map a subdomain of that TLD -- say subdomain.MAPASITE.com -- to a page on the blog, what is the best way to do so?
I thought about .htaccess and 301 redirects but am not sure if there might be a simpler c-Record or forwarding method direct from the Registrar? Thanks for the help.
I don't know if it works for wordpress pages aswell but you can make virtualhosts in your apache installation and set a different document root for a subdomain. I use this, but I don't use wordpress.
In case this might solve it: to change the documentroot (where the user lands when visiting a domain) just make a new .conf file in the directory where your apache installation stores its configs. These lines should do it:
<VirtualHost *:80>
DocumentRoot /var/www
Options -Indexes
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/somemap
ServerName subdomain.example.com
ErrorLog /var/log/apache2/someerrorlog
CustomLog /var/log/apache2/someaccesslog combined
Options -Indexes
</VirtualHost>
You can skip the ErrorLog and CustomLog parts if you don't want a separate errorlog and accesslog for the subdomain.
The first <virtualhost> is to set the default documentroot, just point it to whatever it now is. Since you use a MS installation it certainly is different since mine is from a Debian install.
I hope this gives a solution to your problem.

How to enable wordpress website locally on network and via localhost

My wordpress site works fine on my mac via localhost, using Xammp. I want to view the site on my iPhone. So I type in 192.168.0.2 and voila, it brings up my localhost directory. I then click on the site in question and the content is there but no styling or images. I realise that this is because the paths to all the resources is hardcoded into the wordpress database. So when I am accessing the url via 192.168.0.2/mywebsitename on my iPhone, it's looking for all the resources using a base url of localhost/mywebsitename. Localhost path doesn't exist on my iPhone, only 192.168.0.2 does.
So has anyone found a solution to this little issue? How can I see a wordpress installation by ip address and by localhost access?
For this exact issue, before developing a website. You must create a domain(VirtualHost in apache)
Add the following contents in the file httpd-vhosts.conf, make sure it is included in Apache Configuration. This line ( Include conf/extra/httpd-vhosts.conf ) should be present in httpd.conf
Contents of httpd-vhosts.conf:
NameVirtualHost 192.168.1.26:80
<VirtualHost 192.168.1.26:80>
<Directory "e:/program files/ampps/www/mywebsite">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName 192.168.1.26
ServerAlias 192.168.1.26
ScriptAlias /cgi-bin/ "e:/program files/ampps/www/mywebsite/cgi-bin/"
DocumentRoot "e:/program files/ampps/www/mywebsite"
ErrorLog "E:/Program Files/ampps/apache/logs/192.168.1.26.err"
CustomLog "E:/Program Files/ampps/apache/logs/192.168.1.26.log" combined
</VirtualHost>
(Change the path, ip, etc according to your need). Now after adding the contents. Restart Apache. Now when you access 192.168.1.26 (in my case) from other machine in your network or your same machine. You should see the contents of mywebsite folder directly(or contents index.php if it has any). Now install wordpress using the ip you specified(browser should have that ip in the address bar), in my case 192.168.1.26.
Well I use AMPPS to avoid this headache. It allows me to create domains locally. Also if I have bought a domain say mywebsite.com and i want to add a customized wordpress site on, I create a the domain in the AMPPS with the same name. So the URL of my live website and the local are same. :) Then I simply put the files directly on my server via FTP and obviously import the database on my server.
EDIT: BTW, AMPPS allows to install WordPress in a single click. It has simple interface where you can specify AMPPS to install the WordPress on the created Domain.

Hosting multiple domains in Apache2 - how?

Although I’ve found related articles on stackoverflow, I have seen various suggestions which I’ve tried out but I still experience problems, so that’s the reason why I’m posting this.
I have a question which involves DNS, Debian, Apache2 and Wordpress. I’ve been struggling with this for some time now and haven’t been able to solve it. My current conclusion is that 2there is something with my dns and apache virtual host definitions”, but, as I said I’m far from sure.
This is what my config looks like:
two domains which I “own” hosted by moniker.com - let’s call them domaina and domainb
a hosted vps with Debian, apache2 and wordpress. The vps has ip x.y.z.t
each domain has three ‘A’ records defined: ‘*’, ‘#’ and ‘www’
URL rewrite enabled (a2enmod rewrite)
Wordpress installed and links created to the wordpress directory for both document directories specified in the virtualhost directives below
Both ‘domaina’ and ‘domainb’ point to my vps and this is working ok. However, what I’ve been unable to solve is to have the vps handle “multiple virtual hosts”. I thought I would be able to handle this by using virtual hosts in Apache. For that purpose I’ve defined two sites under /etc/apache2/sites-available which looks like this:
(file: /etc/apache2/sites-available/domaina.com)
<VirtualHost x.y.z.t:80>
ServerName domaina.com
ServerAdmin me#domaina.com
DocumentRoot /var/www/domaina.com
DirectoryIndex index.php
<Directory /var/www/domaina.com/>
AllowOverride all
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
(file: /etc/apache2/sites-available/domainb.com)
<VirtualHost x.y.z.t:80>
ServerName domainb.com
ServerAdmin me#domainab.com
DocumentRoot /var/www/domainb.com
DirectoryIndex index.php
<Directory /var/www/domainb.com/>
AllowOverride all
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Now, when I try to address the sites above from a web-browser I end up at the default apache directory with the index.html file rendered in the browser instead of arriving at the two different wordpress configurations. Obviously there’s something wrong with my thinking around “VirtualHosts” and/or DNS-configurations…
I forgot to mention that I've made loads of /etc/unit.d/apache2 restarts... Sorry...
Frankly speaking I’m lost here and any help on this would be very much appreciated.
Cheers
If you did restart apache and its still not working please respond, as I have experienced similar issues with Apache, especially when getting the virtual host to work. I realise your running on Debian which is different to WAMP, but this is what I do when opening a new virtual host.
First I add the domain to the windows system 32 drivers etc hosts file, it allows for intranet
127.0.0.1 domainname and this stops the url from looking to the web.
Then I have to add the corret directories to the www/your folder.
Just inside the root folder there ought to be a directory called vhosts,
I had to make totaly empty instances of the conf files with just the filename of the virtual hosts inside it so that the changes you made to the httpd-vhosts.conf works.
So what you will need to do is find the wamp/bin/apache/Apache2.2.21/conf/extra/httpd-vhosts makes sure that you have the one from the conf/axtra and not conf/orginal.
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/**name of the folder**"
ServerName **as_inserted_in_hosts**
<directory "c:/wamp/www//**name of the folder**">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>
Save. Apache stop all services, I also have to restart the service running the intranet in windows to update the changes to the hosts file and then restart apache.
This is what I have to do so that when I open localhost from Apache it allows me to see the links appear under virtual hosts as well as the directories appearing under your projects.
Have a look at this tutorial... Explains how to set up virtual hosts
Do you have a NameVirtualHost directive in your apache2.conf anywhere? You'll need that to enable virtual hosting. It can go in apache2.conf or any file included by apache2.conf. On my server I've got it in ports.conf.
NameVirtualHost *:80
See http://httpd.apache.org/docs/2.2/vhosts/name-based.html#using

Resources