I am facing a similar problem as this question where I am using Nginx as a proxy for Apache server (Ubuntu) running WordPress. The internal links of the website all give 301 redirects to localhost.
For instance, the link: wwww.example.com/internal-link
redirects to localhost/internal-link
which gives error 404.
The Apache configurations are as follow:
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
ServerAdmin [email protected]
ServerName example.com
ServerAlias www.example.com
ServerAlias *.example.com
DocumentRoot /var/www/html
...
The Nginx configuration file is as follow:
server {
# Where IP is server IP and example is the domain name
listen IP:80;
server_name static.example.com;
location / {
proxy_pass http://localhost:8480;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen IP:80;
server_name example.com;
rewrite ^ $scheme://www.example.com$request_uri redirect;
}
server {
listen IP:80; # your server's public IP address
server_name www.example.com; # your domain name
location / {
proxy_pass http://localhost:8020;
proxy_set_header X-Real-IP $remote_addr;
}
}
The .htaccess
is the default generated by WordPress:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
here is some of the records for Apache's access log:
10.0.2.2 - - [15/Jul/2016:07:11:31 -0400] "GET /link/ HTTP/1.0" 301 335 "-" "Mozilla/5.0 (compatible; Cliqzbot/1.0 +http://cliqz.com/company/cliqzbot)"
10.0.2.2 - - [15/Jul/2016:07:08:02 -0400] "GET /link/ HTTP/1.0" 404 5396 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0)
any idea what is causing this and how to fix it?