Why is WordPress redirecting to localhost - wordpress

I have a WordPress website running on a server, using a docker container (with port forwarding 8001:80), and an Apache server with proxypass to redirect "demo.travel-itineraries.com" to "localhost:8001".
My problem is that WordPress redirects to localhost instead of using the website URL I specified.
My WordPress configuration doesn't contain any "localhost" occurrence (I tried SELECT * from wp_options where option_value like '%localhost%'; and there is no occurrence of localhost)
The WordPress address is set correctly
The homepage is working fine (http://demo.travel-itineraries.com/) but the second page isn't. If you check the link in the navbar, it's a link to "http://demo.travel-itineraries.com/les-joyaux-de-ladriatique-a-bord-du-pacific" but WordPress redirects to "http://localhost/les-joyaux-de-ladriatique-a-bord-du-pacific".
I checked with curl, and the RedirectedBy header is set to "WordPress".
Do you have any idea why it keeps redirecting?
Thanks

Worth a try: There is an extremely old bug in Wordpress which causes problems in permalinks (i.e. pages are not found) after moving the site to another server or directory even though everything is set correctly.
And there's the also-extremely-old fix for it to go to the backend, open the Settings > Permalinks page, change any one little detail, change it back again and click "save changes". And I've heard from others that often it's even enough to just open that Permalinks page without changing or saving anything.
I just had that again in the current version (5.8.3) – same problem, same fix. I really wonder why that bug still exisits...

I noticed Yoast is installed, the premium version of that plugin automatically creates redirects, you can check those by going to SEO > Redirects in the back-end.

Related

Mixed Content: The page at 'https://example.com' was loaded over HTTPS, but requested an insecure stylesheet error in Wordpress site

Instead of genuine Mixed Content issue this seemed like more of a Wordpress issue hence posting here to find a resolution.
I have everything setup to work with https, though there is no valid certificate yet. here is the home page url https://tourpoule.nl. The home page loads but with Mixed content errors which seem to be generated by core Wordpress or theme functions. Attaching image:
Database does not have any url which would start with http://. I already have replaced them using search and replace script.
There is nothing in htaccess file except basic Wordpress setup code. I tried renaming it as well. I cleared all types of cache but still it does not work. The site is using twentytwenty theme and if I comment out css and javascript enque lines, some of the errors disappear but styles and scripts do not load(that is normal I know).
In the view source of page it shows mixed urls, some with https and style and javascript urls without https. see below:
Interestingly if I click a stylesheet url i.e. http://new.tourpoules.nl/wp-content/themes/twentytwenty/style.css?ver=1.0 it redirects to https://new.tourpoules.nl/wp-content/themes/twentytwenty/style.css?ver=1.0
I am not sure what is going on and have got struck. I am not able to reach the client so that we can discuss turning ssl redirection off in nginx for this domain where it is redirecting everything to https if it is not https. Not sure if that is causing issue (I believe it is not as it has nothing to do with Wordpress mechanism to generate urls). Any help or direction is greatly appreciated.
I can see your website is still unsecured, for what it's worth, get yourself letsencrypt ssl.
Back to you question, go to your database, open the wp_options table, change the siteurl item to https://tourpoules.nl and also change the home item to https://tourpoules.nl.
If you have used search and replace DB master script or plugin it will not update inside meta files as well as and check for the function file have you Enqueue with https://
So will be better if you download SQL file and replace with below:
From:
http://new.tourpoules.nl
To
https://new.tourpoules.nl
and re-upload again

301 redirect error with wordpress and apache

I've recently migrated a database from windows using bitnami (apache and wordpress) to a linux server (apache and wordpress). I'm able to access the website wp-admin, but every time I try to access the main site it repeatedly returns 301 errors.
I've tried disabling the .htaccess file (deleting, commenting everything out), but it still gets directed. I've disabled all plugins. I've looked into the themes I'm using but they don't have redirect url's like I've seen in other posts.
I'm wondering if the issue might be in how bitnami structures itself. the main documents are stored in website/wordpress/htdocs, whereas linux wordpress seems to store it directly in wordpress.
I've set sites-enabled home directory to
sitelocation/wordpress/htdocs
I've also set the wordpress address and site address to
http://website.com:80
What do I need to do to prevent the redirects, or set it up to work correctly?
if you haven't change your Site URL then.
Please change the Site URL and Home URL from database in wp_option table.
You need to mention new url in both section..
I had a trailing / on my siteurl which led to it not working. After removing that it worked.

Wordpress site - too many redirects when selecting link

I have looked at similar questions but still receive the redirect error.When landing on a homepage URL the site resolves and displays for example http://www.test.co.uk . When selecting any link ie. http://www.test.co.uk/products the browser throws a "Too many redirects" error and the site become unusable. The only way I can get it back up is by clearing cookies and cache and trying again. What I find really confusing is that copying the http://www.test.co.uk/products link or manually typing the URL in resolves the URL correctly and I don't get "too many redirects" error. It only happens when I select a link.
I have tried the following:
Renamed the "plugins" directory to "plugins1" to disable the plugins
Reverted to the default wordpress ".htaccess" file
Ensure the site settings URLS matched in wp-admin area
SSL is enabled on the site but not configured to be used anywhere, all links (that I'm aware of reference http://)
Checked any redirects on the hosting via CPANEL (none exist)
Added these to the wp-config file
define ('WP_HOME','http://www.test.co.uk');
define('WP_SITEURL','http://www.test.co.uk);
I'm not sure whats changed in the last couple of days but we think a plugin got updated. Would disabling the plugins prove that its nothing to do with plugins?I'm new to WordPress so apologies if I got some terms wrong.
Any suggestions I could try looking at would be helpful.
Thanks
try to set Home url and site url to http://www.test.co.uk from your WP admin panel

Wordpress links pointing to the wrong domain

In wordpress, how can I change where the links are pointing to without changing the server name or adding redirection?
My main site is a rails app at www.example.com.
I have the wordpress blog on a separate server at blog.example.com/blog
I have a reverse proxy on the primary (rails) server that takes any url that ends in /blog/ and then serves up the blog content. (That's all behind the scenes -- the user never sees the blog.example.com domain)
Currently, I can access the blog via the reverse proxy at www.example.com/blog, but the problem is that the urls on the blog point to blog.example.com/blog (wrong) instead of www.example.com/blog (right).
I've tried changing the urls in wp-config.php, but whenever I change those it breaks something.
I eventually figured it out. Here's what I did.
1) Got rid of the Bitnami wordpress image (on Amazon) and reinstalled wordpress fresh, from scratch, on EC2. Bitnami had a bunch of magic behind the scenes that was making it hard for me to figure out what was going on.
2) Via wordpress admin changed Site Address (URL) from http://blog.example.com/blog to http://www.example.com/blog Previously, I had been changing this in the wp-config.php file, but I am pretty sure that doesn't do the same thing. So I needed to change it in wordpress admin. However I needed to keep the Wordpress Address the same. Found out that the Site Address governs the urls displayed in the theme, whereas the Wordpress Address is the server hostname. I'm using a reverse proxy which is why this was confusing.
3) To enable pretty permalinks behind the reverse proxy I changed the permalink settings in wordpress admin, then I updated .htaccess according to its instructions, then I modified /etc/apache2/sites-enabled/000-default changing AllowOverride None to AllowOverride All. Need to do this to enable mod_rewrite to work on virtual hosts.
Go to wp-admin - settings, and change site url. Than flush permalinks by resaving settings.
You don't really provide a mountain of information. But you will need to check this area of your dashboard
http://www.steveovens.com/wp-content/uploads/2011/09/wpid209-Check__Force_HTTPS_in_site_address__Wordpress_address.png
to make sure the information is
http://54.235.249.193/blog/
In both fields.
If you still have issues try changing your permalink setting to a new setting save it and then change it back again and save.
http://www.webmikesites.com/wp-content/uploads/2013/09/permalink-settings.png
If you are unable to access the dashboard of the site on the address
http://54.235.249.193/blog/wp-login.php
As it redirects you to the other domain.
Then you need to likely change the two fields mentioned earlier siteaddress and wordpressaddress via the database. Find the table in your database wp_options or yourtableprefix_options and edit the fields option_value where the option_name is siteurl and home to have the address
http://54.235.249.193/blog/
Also if you are just starting using a webserver. You may need to make sure your files are writable by the webserver.

localhost redirecting to search page

I have dowloaded wordpress 3.5 and xampp and they are succeessfully insatlled in windows 7 and also changed the wp-config.php file in wordpress and placed it in ht docs and also created a database. My problem is when i load localhost/phpmyadmin it appears and when i load localhost/wordpress/wp-admin/install.php it takes me to my home page which is http://static.flipora.com/websearch.html?ref_type=redirect&src_type=bg&tv=7.104&t=7.104&u=12606685. It takes here whenever i type localhost/(anything). Please tell me there is problem with my xampp or wordpress.
That's most likely malware.
See this to remove it
Some browsers need http:// prepended before localhost and similar URLs to work. On Chrome I need to add the http:// part to access localproject.dev URLs properly (otherwise it redirects to Google search). Firefox seems to work normally with these kinds of URLs.

Resources