logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: New host ignores rewrite rule... why?
Author
jhsachs



Joined: 03 Aug 2010
Posts: 8
Location: Northern California

PostPosted: Sun 26 Feb '12 7:54    Post subject: New host ignores rewrite rule... why? Reply with quote

I'm moving a working site to a new host, and I've got a puzzling problem with URL rewrite rules.

The new host is giving me 404's when I try to load a page that requires rewriting. It appears to be simply ignoring the rewrite rule.

For example, the URL http://www.mysite.com/list-Topics-OMH should be rewritten to http://www.mysite.com/list.php?Topics=OMH. On the old host, it is; on the new host, it isn't.

I've spoken to the new host's tech support about this. They've confirmed that the htaccess file is working in other respects (and I've since confirmed this myself). They say it must be a programming problem, not a system problem.

They speculated that it's due to some difference in the way the rewrite module works between the version of Apache on my development system (2.2.17) and their version (2.2.22). That seems unlikely to me, but I don't know what else to suspect.

Here's the contents of the htaccess file:

Code:
RewriteEngine on
Options FollowSymLinks
#RewriteBase is not needed because we are not rewriting the directory name.
#This rule transforms "list-t-key" to "list.php?t=key".
RewriteRule ^list-(.*)-(.*)$ list.php?$1=$2


Any suggestions? If it's something weird in htaccess, how can I find it? If not, how might I prove that and force them to look farther?
Back to top
Rocker



Joined: 26 Feb 2012
Posts: 16
Location: Brazil

PostPosted: Tue 28 Feb '12 5:35    Post subject: Reply with quote

Only a guess (I could be wrong, I'm a newbie): but I suspect that Apache doesn't have mod_rewrite enabled...

Call them again and say that your files were working fine on another server.
Back to top
jhsachs



Joined: 03 Aug 2010
Posts: 8
Location: Northern California

PostPosted: Tue 28 Feb '12 17:49    Post subject: Reply with quote

Thanks for your interest. As it turned out the problem was a bug in my code, augmented by a bug in the IDE I use, a bug in PHP, and misleading wording in the 404 page.

The bug in my code was a class method defined like this:

Code:
public public function xyz(...) {
   . . .
}

The bug in PHP was that in the versions on my development system and the old host, my buggy code worked just fine. The bug in my IDE was that its syntax check considered the code just fine, too. But the new host's PHP engine choked on it.

The misleading 404 message displayed the original URL, not the rewritten one, leading me to form a reasonable but entirely false theory of what was wrong.

Why I got a 404 at all is a mystery that may never be solved.

Anyway, when I stumbled across the cause of the problem and fixed it, everything started working.

The lesson learned is: when a problem doesn't make sense, question every assumption... especially the ones you don't realize you made!
Back to top


Reply to topic   Topic: New host ignores rewrite rule... why? View previous topic :: View next topic
Post new topic   Forum Index -> Apache