I've recently moved some PHP files from an Apache2.2 server on Windows 7 to an Apache2.4 server on Ubuntu. However, I'm now getting errors resolving URLs. When I click a link to something like https://www.example.com/index.php?page=home, I get a 404 because I'm redirected to https://www.example.com/page=home. However, when I type in the URL manually, it works. Does anyone know of a solution to this problem?

UPDATE: Actually, I was mistaken, the new server is an Apache2.2 server.

UPDATE: Here's the Directory tag from the VirtualHost config file.

<Directory /var/www/site1>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
  • 1
    Post some configs please. You should always do that in case something of a configuration appears to be wrong. – Lukas Mar 12 '13 at 23:54
  • Check that you have "execcgi" option set and that you're loading the php module. – igelkott Mar 13 '13 at 0:01
  • It already displays PHP pages, including retrieving data from a MySQL database. However, the URLs are the issue. – Eric Mar 13 '13 at 0:04
  • If it works because you are retyping the link exactly as it is in the <a> tag, then either something in index.php is redirecting you based on referrer or something in your config is redirecting you based on referrer. – DerfK Mar 13 '13 at 0:07
  • 1
    Configs, and actual examples. "Something like" isn't going to cut it here, I suspect. – Michael Hampton Mar 13 '13 at 0:19

You’re not providing a lot of details here, but it sounds like maybe some Apache mod_rewrite configs in your .htaccess file on the root are acting oddly.

Another issue that might be in play is the root URL setup on your website is misconfigured. So it’s not properly forming URLs.

But you are not explaining what kind of PHP site this is. Is it a CMS? Is it something common if not? Or is it homebrewed PHP?

| improve this answer | |
  • There are no .htaccess files in the directory and mod_rewrite is disabled. It's a custom-made PHP system. I'll post the directory tag from the VirtualHost config file. – Eric Mar 13 '13 at 1:04
  • Ok, it's posted in the question above. – Eric Mar 13 '13 at 1:08
  • Sorry, but that’s not enough to help. Too in the dark. But I can assure you that the version of Apache2 is not at fault. I’ve migrated tons of Apache sites & it’s an extremely backwards compatible piece of software. My guess is there are configuration paths or settings in your custom PHP coding that is causing the issue. But again, it’s almost impossible to say without really looking at your local setup. – Giacomo1968 Mar 13 '13 at 1:12
  • I've written a small test page for arguments and it encounters no issues. I'll look into my application as the source of the problem. – Eric Mar 13 '13 at 1:39

I figured it out. The problem was entirely in my own PHP code. I was having the page redirect with a location header, but I used the wrong $_SERVER variable. I've corrected this and the page is now working like it should.

Thanks to everyone who helped along the way. You guys helped me narrow down the problem to the eventual solution.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.