htaccess rewrite not working when moved server

Discussion in 'Apache' started by rknuppel, Jun 9, 2008.

  1. #1
    Need a little help as I'm stuck here. Recently moved all my sites to new server. One site is giving me fits. It's a custom developed PHP site. Has .htaccess file with rules such as:

    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /

    RewriteCond %{REQUEST_URI} ^/([a-z0-9,\_]+)/details
    RewriteRule ^(.*) /event_details.php?event=%1 [L]


    The simple test page of event_details.php contains:
    <?
    $strThisEventShortName = $event;
    echo "short name is $event<BR>";
    ?>

    On my NEW server this $event variable returns nothing. It's like the rewrite rules broke on the new server. mod_rewrite is installed so thats not it. Anything I'm doing wrong in this code? What would have changed from server to server?

    Thanks!
     
    rknuppel, Jun 9, 2008 IP
  2. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #2
    Umm.. I don't know but try using $ instead of % in the second line.
     
    Lordo, Jun 9, 2008 IP
  3. rknuppel

    rknuppel Well-Known Member

    Messages:
    753
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    153
    #3
    Thanks for the reply. Just tried that. Same result. When I go to:

    http://www.FAKEURL.net/test/details

    I expect to see "short name is test" but I see "short name is "

    Seems like something isn't turned on or some option is missing on this new server setup. Anyone?
     
    rknuppel, Jun 9, 2008 IP
  4. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #4
    Remove the RewriteCond line and replace the second line with:

    RewriteRule ^/([a-z0-9,\_]+)/details$ /event_details.php?event=$1 [L]
     
    Lordo, Jun 9, 2008 IP
  5. rknuppel

    rknuppel Well-Known Member

    Messages:
    753
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    153
    #5
    That gave me a 404 not found:

    Not Found

    The requested URL /test/details was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


    Really appreciate your help!
     
    rknuppel, Jun 9, 2008 IP
  6. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #6
    :)
    OK please PM me the htaccess content after my modifications.
     
    Lordo, Jun 9, 2008 IP
  7. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #7
    Thank you. This worked for me:

    RewriteRule ^([a-z0-9,\_]+)/details$ event_details.php?event=$1 [L]

    If I put it in a folder, say "folder", this worked:

    RewriteRule ^([a-z0-9,\_]+)/details$ folder/event_details.php?event=$1 [L]
     
    Lordo, Jun 9, 2008 IP
  8. rknuppel

    rknuppel Well-Known Member

    Messages:
    753
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    153
    #8
    I know it... It sucks because all of this works (worked) on my other server... Not on the new server for some reason. Same code... Different results. Has to be something in my apache/php install I think - but not sure what.
     
    rknuppel, Jun 9, 2008 IP
  9. rknuppel

    rknuppel Well-Known Member

    Messages:
    753
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    153
    #9
    Anyone else? I have tried all PM'd suggestions. What am I missing here?
     
    rknuppel, Jun 13, 2008 IP
  10. IwhiC

    IwhiC Peon

    Messages:
    2,594
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Check with your new host! Ask them if they are using suPHP as DSO or CGI ?

    From there you may have a issue if the above is true and you are switching from PHP as DSO

    Do they even support rewrite?
    Thank you
    Jason
     
    IwhiC, Jun 14, 2008 IP