Redirecting a domain to another that hosts a wordpress site, getting database errors - wordpress

Originally I had mydomain.com.au, but then I let it expire as I cancelled my abn. After that I started using mydomain.info instead to host my WordPress site. Recently I had my abn re-instated so I have mydomain.com.au back again finally.
I decided to do a permanent redirect from mydomain.com.au to mydomain.info, and I put this in /etc/apache2/sites-available/mydomain.com.au.conf file:
<VirtualHost *:80>
ServerAdmin me#email.com
ServerName mydomain.com.au
RedirectPermanent / http://www.mydomain.info/
</VirtualHost>
It looks the same in /etc/apache2/sites-enabled/mydomain.com.au.conf also.
I reloaded apache2 without error and now I get this error when I try to access www.mydomain.com.au either locally or from an external IP:
Database Error
Error establishing a database connection
I decided to test whether the redirect was working by putting a dummy html file in /var/www/mydomain.com.au. I reloaded apache2 and tried mydomain.com.au again. Still getting the database error.
So now i'm thinking it's a problem with WordPress. Does WordPress not allow you to do this kind of thing?

The redirect was set up incorrectly. It was working for domain.com.au but not for www.domain.com.au. It needs to be:
<VirtualHost *:80>
ServerAdmin me#email.com
ServerName domain.com.au
ServerAlias www.domain.com.au
RedirectPermanent / http://www.domain.info/
</VirtualHost>

Related

My website is showing apache test page

I created website on Amazon Web Server. I route my ip to my domain using ROUTE 53 service. but now my website is showing APACHE TEST PAGE rather then content while if i enter my ip address/wordpress it's working properly.
Any solution please?
maybe you forgot to add a virtual host in http.conf. Apache restart is needed after this.
<VirtualHost *:80>
DocumentRoot "/www/example2"
ServerName www.example.org
# Other directives here
</VirtualHost>
https://httpd.apache.org/docs/2.4/vhosts/examples.html

Home Page Wordpress on Free MAMP does not work

I have installed MAMP (free version) on my Mac and I see the Start Page but I have a problem:
I deployed wordpress but browser say unable to connect (basically I cannot see wordpress page in browser).
In Document Root if I put a static html file I am able to see it in the browser. I am also able to see wordpress administrative pages and all other pages but home page. I have 8888 and 8889 for php and mysql ports. I do not know how to debug the issues. php, apache and mysql do not report any particular problems.
I configured virtual hosts following this guide:
http://foundationphp.com/tutorials/vhosts_mamp.php
The strange thing when I put http://localhost:8888/mywebsite in the browser it is redirected to localhost/mywebsite.
In /etc/hosts I have:
127.0.0.1 localhost
In httpd.conf I activated:
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
and in this file I have:
NameVirtualHost *:8888
<VirtualHost *:8888>
ServerAdmin myuser#gmail.com
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
ErrorLog "logs/mywebsite-error_log"
CustomLog "logs/mywebsite-access_log" common
</VirtualHost>
Hope someone could help.
I found the solution. After several debugging I found that this guide is correct: http://foundationphp.com/tutorials/vhosts_mamp.php
You need: 1. In /etc/hosts add your virtual hosts like:
127.0.0.1 localhost
127.0.0.1 mywebsite
before I only used localhost because I hoped to use this host in browser but I found it's required to define a new host like mywebsite.
In httpd.conf I activated:
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
In this file I have:
ServerAdmin myuser#gmail.com
DocumentRoot "/Applications/MAMP/htdocs"
ServerName mywebsite
ErrorLog "logs/mywebsite-error_log"
CustomLog "logs/mywebsite-access_log" common

Error 503 Service unavailable

just started with Symfony2 and already have a problem that i can not solve.
Installed the Symfony2 demo app on a VPS with debian. but trying to open it give me a "503 Service unavailable".
I used 'symfony demo' to install to /var/www/symfony_demo/
then added a symdemo.conf file to /etc/apache2/sites-available that look like this:
NameVirtualHost XX.XXX.XX.XXX
<VirtualHost XX.XXX.XX.XXX>
ServerName symblog.dev
DocumentRoot "/var/www/symfony_demo/web"
DirectoryIndex app.php
<Directory "/var/www/symfony_demo/web">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
XX.XXX.XX.XXX = public server IP
and activated it with a2ensite symdemo.conf
I thought that would work, but opening the IP give me the error message.
and trying to open app_dev.php give me not allowed to access this file
Could someone please give me a tip?
Nevermind. Looks like i fixed it. Following this tutorial: http://intelligentbee.com/blog/2013/08/07/symfony2-jobeet-day-1-starting-up-the-project/
just activate mod_rewrite with a2enmod rewrite and restart apache. that's it.

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

how to rename your localhost/myfolder in htdocs to some domain name

So we all know that to access your site inside htdocs you have to type "localhost/yoursite folder" right? but i have managed to change that by some help of my friend. now my friend is gone so i cant ask him to change it back. Instead of "localhost/yoursite" i can access it through "mysite.test" it has something to do with host.txt in system32. Now the problem is im installing a new drupal site in htdocs again and i cant access it since my localhost is always pointing to my first drupal site. how do i configure this?
HERE'S MY HOST.TXT
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 activate.adobe.com
127.0.0.1 drupal6.test
127.0.0.1 belmark.test
drupal 6 is my previous site. and belmark.test is the site i want the localhost to direct to which is not working. even if i omit the drupal6.test line localhost still directs to drupal6.test
and here's my httpd-vhost.conf
<VirtualHost *:80>
ServerAdmin cadaybelmark#gmail.com
DocumentRoot "C:/xampp/htdocs/drupal6"
ServerName drupal6.test
ServerAlias drupal6.test
ErrorLog "logs/drupal6.test-error.log"
CustomLog "logs/drupal6.test-access.log" combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin cadaybelmark#gmail.com
DocumentRoot "C:/xampp/htdocs/drupal7"
ServerName belmark.test
ServerAlias belmark.test
ErrorLog "logs/drupal.test-error.log"
CustomLog "logs/drupal.test-access.log" combined
</VirtualHost>
You need to configure apache (via xampp) with additional vhosts, one for each site.
A vhost configuration maps a ServerName with a DocumentRoot. For example,
ServerName localhost
DocumentRoot /path/to/my/drupal
If you want a new, second site, you will need a second vhost for it. If you simply want to replace the original site with a new Drupal installation, your original vhost can stay the same (as long as you put in the exact same place as the original, which it sounds like you did not, since the old site is still loading).
See the XAMPP documentation for how to add/edit vhost entries.
not sure if i understood your problem right
create a subfolder in htdocs and install it there.
127.0.0.1/subfolder/yoursite
My god the answer is so simple. Apache just needs to be restarted. OK! thanks for the efforts guys.

Resources