Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

rewrite rules problem

Options
  • 30-06-2004 3:13pm
    #1
    Subscribers Posts: 1,911 ✭✭✭


    I moved a site to a new server recently and for some reason my rewrite rules are acting slightly differently.

    On the original server, the url in the location bar and the request_uri stays the same (which I want)
    On the new server, the url changes to the url the rule redirects to.

    They're both running apache 1.3.31. I can't see any differences in their configurations. any pointers?

    rewrite rule on old server:
    RewriteRule     ^(.+)$  [url]http://defttest.eeng.may.ie/~draco/main/common/this_file.php?module_id=12[/url]
    

    rewrite rule on new server:
    RewriteRule     ^(.+)$  [url]http://wopr.eeng.may.ie/main/common/this_file.php?module_id=12[/url]
    


Comments

  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    isn't it because the directory paths are different on the servers?


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Draco,

    1) You don't seem to be pulling the content in parentheses into anything in the RewriteRules? There's no point in parenthesising if you're not going to backreference; it's a waste of the processor.

    2) The behaviour on server 1 is absolutely correct, mod_rewrite won't force a redirect unless you pass an [R] flag to it. With this in mind, I'm guessing it's the tilde (~) and paths causing the problem. Have a think about that and I'll come back to it tomorrow, you know, when I'm sober? :)

    adam


  • Subscribers Posts: 1,911 ✭✭✭Draco


    1) I was orginally using a backreference so that's why they're there. Gone now.

    2) My problem is with server two. It is doing the unwanted redirect. I moved stuff around on server one to get rid of the ~ and it's still working as wanted, so it's not that.


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    It's hard to tell from afar to be honest, but it's likely to be a slight difference in environment on the new server. I'd suggest setting up a RewriteLog with the RewriteLog and RewriteLogLevel directives and examining that. If you can't figure it out immediately, set the RewriteLogLevel to 9, call the URL a couple of times, and post the output here.

    adam


  • Subscribers Posts: 1,911 ✭✭✭Draco


    got it this morning. The second server thought it had to do a REDIRECT/302 as the server name was set just to wopr rather than wopr.eeng.may.ie.

    Bah. I knew it was something stupid I had missed.


  • Advertisement
  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Still unusual though, since mod_rewrite is such a low-lying module it usually takes precedence over everything else (Redirect, Alias, etc). Anyway, glad you figured it out.

    adam


Advertisement