4

I have two redirects on my site. One of them is working, and one of them is not. Here are the relevant lines from my configuration, edited to protect the innocent.

<VirtualHost *:80>
ServerName notworking.com
ServerAlias www.notworking.com
Redirect permanent / http://example.com/units/
</VirtualHost>

<VirtualHost *:80>
ServerName working.com
ServerAlias www.working.com
Redirect permanent / http://example.com/widgets/
</VirtualHost>

The second redirect is working fine. When I visit working.com, my logs look like this:

1.2.3.4 - - [06/Feb/2015:16:08:07 +0000] "GET / HTTP/1.1" 301 241
1.2.3.4 - - [06/Feb/2015:16:08:07 +0000] "GET /widgets/ HTTP/1.1" 200 49257

The first redirect is not working. When I visit notworking.com, my logs look like this:

1.2.3.4 - - [06/Feb/2015:16:08:23 +0000] "GET / HTTP/1.1" 200 50003

Here is the VirtualHost configuration from apachectl -S

VirtualHost configuration:
*:80                   is a NameVirtualHost
default server something.example.com (/opt/lampp/etc/httpd.conf:55)
port 80 namevhost something.example.com (/opt/lampp/etc/httpd.conf:55)
port 80 namevhost something.example.com (/opt/lampp/etc/httpd.conf:60)
port 80 namevhost notworking.com (/opt/lampp/etc/httpd.conf:65)
alias www.notworking.com
port 80 namevhost working.com (/opt/lampp/etc/httpd.conf:71)
alias www.working.com
port 80 namevhost example.com (/opt/lampp/etc/httpd.conf:77)
port 80 namevhost www.example.com (/opt/lampp/etc/httpd.conf:82)
port 80 namevhost something-else.othersite.com (/opt/lampp/etc/httpd.conf:87)
alias something-else.othersite.com
port 80 namevhost localhost (/opt/lampp/etc/httpd.conf:95)

Again, all of the other aliases, redirects are working as expected. Perhaps it is something to do with the other one's or the order?

EDIT: a bit of additional information: notworking.com was previously redirected to example.com through DNS. Perhaps this has something to do with it? Is the DNS cached somewhere? I've tried it with a fresh cache in my browser.

4
  • 2
    Did you restart httpd after making the change ?
    – user9517
    Feb 6, 2015 at 19:36
  • @Iain, yeah I restarted httpd after making the change. More specifically, I ran sudo ./lampp stop followed by sudo ./lampp start. The box is running on a xampp install.
    – ctlacko
    Feb 10, 2015 at 16:10
  • 1
    In the working.com VirtualHost, are you redirecting to another page in the same domain? Although that's not what it say in the config (redirects to example.com), the access log shows a 200 OK for what appears to be the same domain, unless all of them use the same log file. Feb 14, 2015 at 11:55
  • Thank you for taking a look, @GustavoMaia. I'm pretty sure the problem is not with Apache. I believe notworking.com is already being redirected by a different web server, so Apache is ignoring the subsequent redirect. I'm just waiting on confirmation from the customer that this is the case, and then I will mark this as answered.
    – ctlacko
    Feb 16, 2015 at 20:15

1 Answer 1

0

The problem here wasn't with my Apache configuration. The customer was using a redirect service from their provider, and Apache won't redirect a redirect.

I considered deleting the question, and still will if the following is considered an invalid reason for leaving it by the community: that someone may have this problem in the future.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .