I have my website and WordPress installed on a Linode server running Ubuntu.
The directories are:
~/public_html - Website
~/public_blog - WordPress installation
My DNS and site config is set up so that:
hashbang0.com - Points to website in ~/public_html
blog.hashbang0.com - Points to WordPress install in ~/public_blog
Site config as follows:
<VirtualHost 123.456.789.000:80>
ServerAdmin user#gmail.com
ServerName hashbang0.com
ServerAlias www.hashbang0.com
DocumentRoot /home/user/public_html/
ErrorLog /home/user/log/error.log
CustomLog /home/user/log/access.log combined
</VirtualHost>
<VirtualHost 123.456.789.000:80>
ServerAdmin user#gmail.com
ServerName blog.user.com
ServerAlias blog.user.com
DocumentRoot /home/user/public_blog/
ErrorLog /home/hashbang0/log/blog_error.log
CustomLog /home/hashbang0/log/blog_access.log combined
</VirtualHost>
Now, I have had enough of tinkering with PHP, HTML, etc. I want to move my WordPress installation so that visitors to hashbang0.com see the WordPress site. At the same time, anyone with links to the old blog.hashbang0.com (most notably RSS feeds and a few links spattered about which gain a fair amount of traffic, etc.) shouldn't be cut off (possibly be redirected to the appropriate thing on hashbang0.com).
I guess I could possibly change the site config to:
<VirtualHost 123.456.789.000:80>
ServerAdmin user#gmail.com
ServerName hashbang0.com
ServerAlias www.hashbang0.com
DocumentRoot /home/user/public_blog/
ErrorLog /home/user/log/error.log
CustomLog /home/user/log/access.log combined
</VirtualHost>
And I guess I'd need to update the URL in Settings > General?
I don't want to start moving stuff and find I've shot myself in the foot. The WordPress howtos are great, but riddled with if this and if that...
Any help would be very much appreciated.
Ben
Ben,
Your best bet is to litterally move the entire blog folder over to your public folder. In this case, you will want to write a redirect htaccess script on the blog subdomain.
RewriteCond %{HTTP_HOST} ^blog\.mydomain\.com$ [NC]
RewriteRule ^(.*) http://www.mydomain.com/$1 [L,R]
In a Command Line Interface, CLI,
You would
cp -r ~/public_blog ~/public_html
make sure to make back ups! And when you are all done, create the .htaccess file in ~/public_blog and delete the old files.
You may want to look into adding a 301 Redirect so google knows you moved also.
Before you do anything, create a copy of this file. Then if you mistype anything, you just overwrite the original with the copy.
Currently your website is located in directory public_blog. To have users access this WP from hash bang, you either need to rewrite the DocumentRoot for hashbang from public_html to public_blog or you need to move the entire site directory structure to the root directory in public_html.
Related
I want to host more WP sites on WAMP server at the same time.
How to do that?
I would recommend you to download XAMPP. Basically WordPress is built on PHP and XAMPP has support for PHP. First download it and configure it then go to the installation directory and go to xampp>htdocs> then make a new folder 'project' and then unzip the WordPress files in that folder. After that read the manual provided ant xampp's website and follow it. Basically you can build your WordPress website on Xampp.
EDIT
Oh sorry for not understanding the question properly.
Now do this.
step 1: host the different websites in htdocs/ folder in xampp. You can host many websites as you want.
step 2: Then go to xampp/apache/conf/httpd.conf and uncomment the line which says this. For uncomment delete the '#' character.
Include conf/extra/httpd-vhosts.conf
step 3: Go to xampp/apache/conf/extra/httpd-vhosts.conf
Create the setup like this
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/xampp"
ServerName xampp
#ServerAlias
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/site1"
ServerName site1.com
ServerAlias www.site1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/site2"
ServerName site2.com
ServerAlias www.site2.com
</VirtualHost>
YES. You can make sub-folders in www and make different WP websites. But be careful with the database configuration. Installing WP does nothing but coping some PHP files to that specific folder. All the data is saved in database and inside that specific folder itself (E.g. config php files).
I have a website, with some content in the root folder.
I then have a Wordpress site in a subfolder of a subdomain. So for example the url to the Wordpress 'contact' page looks like this.
subdomain.mywebsite.com/subfolder/contact/
Is there a way to get this Wordpress site to act as the root of the website without moving files around? Either through an htaccess file or any other method?
It would be important that the user doesn't know they are in a subdomain/subfolder, so for the contact page of the wordpress site the url bar would have to look something like:
www.mywebsite.com/contact/
Would really appreciate any help.
You can do that in the vhost entry of your webserver.
Example main entry:
<VirtualHost *:80>
ServerAdmin xxx#xxx.com
DocumentRoot "c:/Users/xxx/Documents/www/"
ServerName xxx.com
ErrorLog "logs/xxx.error.log"
CustomLog "logs/xxx.access.log" common
</VirtualHost>
Example subdomain entry:
<VirtualHost *:80>
ServerAdmin xxx#xxx.com
DocumentRoot "c:/Users/xxx/Documents/www/subfolder"
ServerName subdomain.xxx.com
ErrorLog "logs/subdomain.xxx.error.log"
CustomLog "logs/subdomain.xxx.access.log" common
</VirtualHost>
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/subfolder/$1 -f
RewriteRule ^([^/]+)/?$ /subfolder/$1 [L]
This will internally map /file/ to /subfolder/file if the requested file exists in /subfolder.
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
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.
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.