Website being directed to <domain>/blog for some reason - php

I set up apache2 server. The following is in /etc/apache2/sites-enabled/default-ssl.conf.
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
...
If I visit https://www.example.com/index.html it displays the content of /var/www/html/index.html file as expected. However, if I just visit https://www.example.com, it redirects to https://www.example.com/blog. I can't find anything in /etc/apache2 directory that contains "blog" at all.
I did try to put a wordpress "blog" folder inside /var/www/html before and have a "blog" database in mysql. But I didn't really get it to work and tried to abandon it. Now it appears I am stuck with it and I can't figure out where it is enabled. I also noticed, if I visit http://www.example.com (not https) it doesn't redirect to /blog but displays index.html content.
Appreciate if anyone can explain how/why apache2 decides to redirect https://www.example.com to https://www.example.com/blog. Thanks.

Login to your WordPress Dashboard, and go to Settings, then General. There will be two entries: WordPress Address and Site Address. It's likely that one or both entries will have "https://www.example.com/blog" as the value. Update these URLs and click on Save Changes at the bottom of the page.
However, if you cannot access the WordPress Dashboard, you'll have to review the database. Check your WordPress database, specifically the "wp_options" table; name varies by prefix, but "wp_" is default. In it, there are 2 entries which tell the WordPress site where it is hosted. Here is the MySQL query you can run to see what it says:
SELECT * FROM wp_options WHERE option_name IN ('home', 'siteurl');
You can update the fields with this query:
UPDATE wp_options SET option_value = 'https://www.example.com/' WHERE option_name IN ('home', 'siteurl') LIMIT 2;
The home (WordPress Address) vs siteurl (Site Address) entries differ in that the home entry is where your site can be reached, and siteurl is the URL of where the site content is located (DocumentRoot). Given your situation, it would appear that your home will have "/blog" and your siteurl will have the correct URL. Here is the WordPress documentation regarding the siteurl entry.
As for http vs https, that would depend on your sites-available configuration, but you can also force https with your .htaccess file, and both home and siteurl URL entries.
EDIT: as a quick fix, you can also update your wp-config.php file for the respective entries, but the better, permanent solution is to use the WordPress Dashboard (or manually updating the database for the same fields).

Related

wordpress in lan, can access wp-admin, but the website always redirected to localhost

hi i have question about wordpress.
i'm already configure siteurl and home as static lan ip.
in another lan computer i can access the admin dashboard wp-admin, http://ipaddress/wordpress/wp-admin
but the wordpress website always redirect to localhost, when i type ipaddress/wordpress. how can i fix this?
I've already changed the configuration in wordpress admin in setting, general.
I've already changed the httpd.conf to listen to ipaddress
I've also tried adding lines in wp-config.php but still failed...
In wp_options table, changed the option_name= siteurl and home option_value to the your ipaddress url

Wordress website infinitly reloads when changing the site and wordpress URL

After a few days of looking around and trying, I do not seem any closer to the solution.
I am running a nginx + WordPress site off of one of my machines. I recently bought a domain name through domain.com. Currently I have my external IP set as both the site and WordPress URL. This works alright but if i try to connect to my domain name and subsequently click on any page of my website, the domain name in the url will be replaced by my external IP. However if I exchange the site and WordPress URL for my domain name (http://domain.xyz) my main page will infinitely reload and my admin panel will no longer be accessible.
How do i achieve the expected site behavior of http://domain.xyz/url, as opposed to http://XX.XXX.XXX.XXX/url ?
thanks for any info you can provide!
I think that there's a wrong URL anywhere in the WordPress configs, so here are a few ideas of what could be the issue and how to solve it:
WP Options
Check for the correct URL in your database. In the table, wp_options, are 2 entries (siteurl and home) with the URL. Make sure that option_value is equal to your path, in your example http://domain.xyz/url.
WordPress Permalinks
If you moved from one domain to another or the directory of WordPress changed, try to reload the Permalink Structure: /wp-admin/ -> Settings -> Permalinks -> Save
SSL, www.
Also, make sure you have the correct URL entered. For example, if you're using SSL, don't use http://example.com/url but https://example.com/url.
Same thing for the www. subdomain if you're using it (or any other subdomain).

Wordpress site - home page opens but inner pages give 404

This seems like very trivial, that its a .htaccess file issue, but it isn't.
I have a wordpress site, which was running at say demo.xxx.com I had to move it to xxx.com
so i just went to my apache and change the files to redirect the same to xxx.com and not to demo.xxx.com
i also went in wordpress and changed the url related settings from demo.xxx.com to xxx.com
the directory thus is the same for this source code.
the home page opens well, at first i thought may be i should reset all the permalinks, which i did but the inner pages refuse to open.
my .htaccess file is same as before, I don;t think there is anything wrong about it.
Have you tried to go to Settings -> Permalinks and choose a setting different from Default, then click the Save button?
When you directed Apache to go to your new site, was it in a different directory? If so, you probably don't have the same directory permissions. Permalinks use mod_rewrite and won't work unless Overrides are enabled.
Check and change your httpd.conf file...
<Directory "/var/www/xxx.dom">
AllowOverride None
</Directory>
to
<Directory "/var/www/xxx.dom">
AllowOverride All
</Directory>

Wordpress Custom Menues

I am currently working on a wordpress multisite project. I have set up a working environment in localhost. In the main menu there is a links to home, so is in subdirectory sites. Now my problem is everything works find in testing server environments as the main site URL is myhost/xx/wordpress_site and sub directory sites are like myhost/xx/wordpress_site/sub_dir. In wordpress Appearance->menu you can only give a static url in the link URL field. What I am looking for is to give a method like site_url().”/sub_dir” in that field so I don’t have to manually alter all the site home URLs when I upload the site to it’s destination domain. Which can be any form?
Any simple solution regarding this problem its greatly appreciated.
Thanks a lot.
I would not recommend to change anything on wordpress code or site url configuration.
because when you will go to production you will have to change it back again.
It will be the best if you will setup the same site configuration on your localhost, you can use the following configuration for your apache server and host file so you will be able to
access your local site by your actual domain.
This way your settings will remain the same and all site links will be the same.
(rename mysite to your site url)
how to change host file:
http://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/
how to add virtual host apache:
http://httpd.apache.org/docs/current/vhosts/examples.html
Apache configuration:
<VirtualHost mysite.com:80>
ServerName mysite.com
DocumentRoot /var/www/mysite
<Directory /var/www/mysite>
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
host file configuration:
127.0.0.1 mysite.com
restart apache and you will be able to work on localhost like it is the productin server.
* Remove the following when you want to access the real server.

apache virtualhost link error

I run a wordpress on AWS, the public domain assigned by AWS is "ec2-23-23-124-60.compute-1.amazonaws.com", and the virtualhost setting is as following:
<VirtualHost *:80>
ServerName remykits.com
DirectoryIndex index.php
DocumentRoot "/home/mysite/sites/blog"
LogLevel info
ErrorLog /var/www/vhosts/domain.com/log/error.log
CustomLog /var/www/vhosts/domain.com/log/access.log combined
</VirtualHost>
but when I click a link in my blog, the url changes to "http://ec2-23-23-124-60.compute-1.amazonaws.com/", I have no idea how to solve it.
I think this more of a Wordpress issue than an Apache one. Go into your Admin panel, go to Options and change your Site URL to point to remykits.com. Your links should now use this as the base_url for the site.
If your Apache configuration was incorrect, your Wordpress installation would most likely not even render. Your ServerName is correct, which is the most important thing.
This needs to be fixed with Wordpress. Wordpress generates links and URLs on your page based on the domain name in the database. Which seems to be ec2-23-23-124-60.compute-1.amazonaws.com. This usually happens when someone installs Wordpress by going to that domain name, rather than your actual domain name (remykits.com). People usually do this because they want to install Wordpress on the server, but don't want to wait for the domain name to point to the server IP while DNS propagates.
Wordpress has a well written Codex page on how to change the domain your Wordpress installation uses. While the codex article goes into detail on how to make these changes manually, the following is all you really need to do.
On the Settings->General screen in a single site installation of WordPress, there are two >fields named "WordPress address (URL)" and "Site address (URL)". These are also known as >the "Home" and "Site URL" settings. They are important settings, since they control where >WordPress thinks your site is located. They control the display of the URL in the admin >section of your page as well as the front end, and are used throughout the WordPress code.
The "Home" setting is the address you want people to type in their browser to reach >your WordPress blog.
The "Site URL" setting is the address where your WordPress core files reside.
Note: Both settings should include the http:// part and should not have a slash "/" at the >end.
Wordpress Codex - Changing The Site URL

Categories