VirtualHost sets the url as abc.com/subdirectory/ - wordpress

<VirtualHost *:80>
ServerAdmin xxx#abc.com
ServerName abc.com
ServerAlias www.abc.com
DocumentRoot /var/www/html/wordpress/
<Directory /var/www/html/wordpress/>
Options All
AllowOverride All
order allow,deny
allow from all
</Directory>
ErrorLog /var/logs/error_wp.log
CustomLog /var/logs/access_wp.log combined
</VirtualHost>
I had issues with Wordpress url, then I changed the url to abc.com and now Wordpress renders all pages correctly.
But when it comes to homepage, abc.com, it redirects to abc.com/wordpress/
So whenever I type abc.com in a browser, it redirects to abc.com/wordpress/
And it says "Oops! That page can’t be found."
Wonder where the issue might be.
I'm using default .htaccess for Wordpress. I use a static homepage. Except homepage all other pages work properly. I am able to login using abc.com/wp-admin/
Thanks in advance.

Your directory block should list the path relative to the root, not the absolute path. See if this fixes it:
<Directory />
Options All
AllowOverride All
order allow,deny
allow from all
</Directory>
Also, you shouldn't include a trailing slash with your document root.
DocumentRoot /var/www/html/wordpress
Here's the entire corrected config file:
<VirtualHost *:80>
ServerAdmin xxx#abc.com
ServerName abc.com
ServerAlias www.abc.com
DocumentRoot /var/www/html/wordpress
<Directory />
Options All
AllowOverride All
order allow,deny
allow from all
</Directory>
ErrorLog /var/logs/error_wp.log
CustomLog /var/logs/access_wp.log combined
</VirtualHost>

The problem was pretty silly. I had set a static page as homepage, which had an entry in db as abc.com/wordpress/. So everytime I click homepage, it would search for abc.com/wordpress/wordpress, which doesn't actually exist.

Related

Apache2 shows default page even after disabling it

I've moved a wordpress site to an Ubuntu Server. While I access it from localhost everything works fine but when I try from my public IP address I can only see the apache2 default page.
I tried everything:
Disabled 000-default.conf and enabled mine
Deleted the default HTML page
Added AllowOverride All
Here there's my Virtual Host file
<VirtualHost *:80>
<Directory "/var/www/exidis">
AllowOverride All
</Directory>
ServerName alternanza.duckdns.org
ServerAlias www.alternanza.duckdns.org
DocumentRoot /var/www/exidis
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Thanks in advance for any suggestion

Virtualhost problems. Have two vhost files but results are unexpected 2nd site does not load properly

I have 1 ubuntu 14.04 server from DO and two independant WordPress installations I'm trying to run off the same server
Have two apache vhost config files:
000-default.conf and 001-default.conf
Now when navigating to domain1.com everything works flawlessly. The entire website is working as expected. But there is a problem with going to domain2.com it will automatically redirect to domain1.com. Basically the problem is I can't get to the WordPress installation screen on domain2.com
Here is the conf file under sites available for domain1.com (000-default.conf):
<VirtualHost *:80>
ServerAdmin email#gmail.com
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
config file for domain2.com (001-default.conf):
<VirtualHost *:80>
ServerAdmin email#gmail.com
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /var/www/htmlposts
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/htmlposts>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Additional information:
In /var/www/html I have the WordPress files for domain1.com and everything works.
In /var/www/htmlposts/ I have extracted the WordPress files for domain2.com
it looks like this: http://prntscr.com/d4h9gu
I have created an index.html file in /var/ww/htmlposts which is the directory for domain2.com and when I navigate to domain2.com/index.html the file displays as expected but when I navigate to domain2.com/wp-admin/install.php which should start the wp installation process for instance #2 "domain2.com" it shows an already installed error which looks like this: http://prntscr.com/d4hhav
There are two databases on the server. One is for domain1.com and the other database is an empty one that I created for domain2.com. Both are correctly pointed in their respective wp-config.php files.
Can you compare the config.php of the 2 sites. Make sure that the database names in both the config.php files are different.

I'm trying to use my other domain

I just got a new domain and i'm trying to use it for a different site but I can't get it to work. It still sends me to my other domain name instead. I try to look it up how to do it but I can't find away to do it, What should I do?? Here is the code,
ServerName dstokesncstudio.org
<VirtualHost 69.132.203.191:80>
ServerName dstokesncstudio.org:80
ServerAlias www.dstokesncstudio.org
DocumentRoot "C:/htdocs/www/dstokesncstudio"
DirectoryIndex index.html
TransferLog "C:/htdocs/www/dstokesncstudio/logs/access.log"
ErrorLog "C:/htdocs/www/dstokesncstudio/logs/error.log"
<Directory "C:/htdocs/www/dstokesncstudio">
DirectoryIndex index.html
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
ServerName dejesusconstruction.com
<VirtualHost 69.132.203.191:8080>
ServerName www.dejesusconstruction.com:8080
ServerAlias www.dejesusconstruction.com
DocumentRoot "C:/htdocs/www/dstokesncstudio/jesus"
DirectoryIndex index.html
<Directory "C:/htdocs/www/dstokesncstudio/jesus">
DirectoryIndex index.html
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 69.132.203.191:80>
ServerName dstokesncstudio.org
</VirtualHost>
<VirtualHost 69.132.203.191:8080>
ServerName dejesusconstruction.com
</VirtualHost>
As
http://ping.eu/nslookup/
say
dstokesncstudio.org => 216.239.38.21,216.239.32.21,...
dejesusconstruction.com => 216.239.38.21,216.239.32.21,...
not 69.132.203.191
I think you want name based virtual hosts https://httpd.apache.org/docs/2.4/vhosts/name-based.html
In your case remove the ServerName ... outside of the VirtualHost ... and add on top
NameVirtualHost *:80
NameVirtualHost *:8080
If you also want to reach the second domain also on port 80 then you dont't need the second line.
Now remove the IP from the VirtualHost as the link above have described and voila you should reach the domains.

Can't get to subsites. Wildcard-subdomains probably misconfigured in Apache

I'm building a portal for the organization I'm working at.
The portal is a Wordpress site using Wampserver 2.5, intalled on a Win server 2008 R2.
It's working fine and accesible from other machines over the intranet, thanks to the helpful and patient RiggsFolly.
But now, I have changed it into a network of sites so that I can build sub-portals for the different departments in my organization.
During that change Wordpress gave this warning message: Warning! Wildcard DNS may not be configured correctly!
Wordpress has a page explaining how to configure wildcard subdomains on Apache - http://codex.wordpress.org/Configuring_Wildcard_Subdomains.
I tried following it but the explanation lacks details and I'm probably doing something wrong.
On the machine where the servers and site are installed, when I write http://hipo (hipo is the current site name) in the browser's address bar, I get to the site fine.
But when I write http://depa.hipo (depa is a subsite I created successfully), the address changes into http://www.depa.hipo/ and the browser says it didn't find a server at that address.
I have probably set the ServerAlias line wrong in httpd-vhosts.conf, and also I didn't add the line *.example.com A 192.0.43.10, or in my case *.hipo A <rightIP>, cause I wasn't sure where to add it in the file.
This is my httpd-vhosts.conf file. Your help is appreciated!
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/hipo"
ServerName hipo
<Directory "c:/wamp/www/hipo">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/hipo"
ServerName subsites.hipo
ServerAlias *.hipo
<Directory "c:/wamp/www/hipo">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp/www">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
This definition does not have a ServerAlias so try adding one like this:
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/hipo"
ServerName hipo
ServerAlias www.hipo
<Directory "c:/wamp/www/hipo">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

How to point URL path to a wordpress folder

I currently have two sites, hosted on the same server using Apache virtual hosts.
http://www.example.com -> /var/www/sites/mysite (path to main website)
http://blog.example.com -> /var/www/sites/blog (path to wordpress folder)
I need my blog to be accessible from www.example.com/blog
I cannot move the wordpress installation into a 'blog' subdirectory of the mysite folder.
Using the Apache Alias directive, I can do the following in the configuration for www.example.com:
Alias /blog /var/www/sites/blog
and access the blog via www.example.com/blog
However the following fails to work with a 404
www.example.com/blog/a-permalink-post-title
I have also tried using the following but the 404 still persists.
AliasMatch /blog/(.*)$ /var/www/sites/blog/$1
The current virtual host configuration looks like this:
<VirtualHost *:80>
ServerName www.example.com
Alias /blog /var/www/sites/blog
DocumentRoot /var/www/sites/mysite
<Directory /var/www/sites/mysite>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
and for blog.example.com
<VirtualHost *:80>
ServerName blog.example.com
DocumentRoot /var/www/sites/blog
<Directory /var/www/sites/blog>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Would greatly appreciate any help with this.

Resources