Our WordPress is installed on blog.survio.cz with defined WP_HOME and WP_SITEURL:
define('WP_HOME','http://blog.survio.cz');
define('WP_SITEURL','http://blog.survio.cz');
However for SEO purposes we redirect it (with 301 redirect) to http://www.survio.com/cs/blog/
The trouble I’m facing is that this redirect screws a lot with WordPress functionality.
The latest problem is that I can’t add comments.
F.e.: in the post http://www.survio.com/cs/blog/novinky/jak-zvysit-pocet-vyplnenych-dotazniku when I scroll down and fill in comment and hit submit (odeslat komentar), I see blank page with URL http://www.survio.com/wp-comments-post.php – the URL is obviously wrong.
My question is: is there a way for me to change, where the wordpress looks for this .php? (It is probably located at blog.survio.cz/wp-comments-post).
2
Answers
I think that you must edit your “options” table. In this table you have two record for “WP_HOME” and “WP_SITEURL”. Edit this two record with address of your domain.
Problem
The problem is that when the comment form is generated WordPress is setting the action with a relative URL.
The browser then fills in that url with
http://www.survio.com/
since it doesn’t know anything aboutblog.survio.cz
. And, of course, http://www.survio.com/wp-comments-post.php doesn’t exist.So, what you need to do is to change it so that the action attribute gets set with an absolute url. But how?
It turns out that in WordPress core, the code that generates that line of HTML starts like this:
Which means that site_url(‘/wp-comments-post.php’) is returning ‘/wp-comments-post.php’. It does that because the site_url function prepends the site_url stored in the WP database before whatever string is passed to it. So, evidently, the site_url in the database.
The Fix
You can probably fix this by setting the site_url to ‘http://blog.survio.cz‘ in your General Options page of your site.