migration mod_rewrite from apache 1.3 to apache 2.2 - all mod_rewrite no longer worki

Discussion in 'Apache' started by hans, Oct 25, 2006.

  1. #1
    Hi all

    2 days ago I had to move from shared hosting to dedicated server - my own boss now - also my own workhorse :) - too much traffic / CPU usage emailed me my host (1and1.com) ....

    with previous apache 1.3 and php4.4 --- ALL worked perfectly !

    now I have apache 2.2 and php5 and nothing at all work re rewriting

    see my php-info
    http://kriyayoga.com/var/php-info.php

    about 70% of my pages are static HTML pages - rest dynamic PHP pges

    before i had several mod_rewrite on my site - all in .htaccess - some simple some quite complex and all worked perfectly all times

    with exactly same mod_rewrite syntax as before - on new server NO mod_rewrite works at all even the most simple.

    I had / have from hotlink rewrite to domain.com ->> www.domain.com - and complex mod rewrite for my gallery2 photo gallery SW - all worked perfectly before

    apache2 is new to me and it appears somehow that i have set at least ONE option or configuration too few ( ... or too much ?? )

    in the apache global conf httpd.conf ( in my suse linux its default_server.conf )

    I have the module mod_rewrite loaded - at least php-info says so
    and i have enabled

    Options MultiViews All ( where "All" should include all incl. option followsymlinks )

    Options +FollowSymlinks

    the most simple code i used before in .htaccess - NOW in the global conf - was

    syntax test says:
    > rcapache2 configtest
    Syntax OK

    any idea what to do to make mod_rewrite system wide working again ?
    any particular technique to migrate all working mod_rewrite code from apache 1.3 to apache 2.2 ??

    help highly appreciated - i have spent the last 2+ days nearly day and night searching G and reading apache2 howtos and manuals with no success so far
     
    hans, Oct 25, 2006 IP
  2. ilja

    ilja Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    u have to check the logs on the server!!!
    take a look in /var/log/auth.log or /var/log/apache2/...
     
    ilja, Oct 26, 2006 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #3
    Post the code you got for changing the URLs.
     
    Nintendo, Oct 26, 2006 IP
  4. Shoemoney

    Shoemoney $

    Messages:
    4,474
    Likes Received:
    588
    Best Answers:
    0
    Trophy Points:
    295
    #4
    the configtest is just checking your server config not your .htaccess
     
    Shoemoney, Oct 26, 2006 IP
  5. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #5
    Shoemoney
    configtest of course is done

    ilja
    error log show nothing - they only show if something is done at all and done wrongly - in my case i know that I MYSELF simly forgot to activate somethng important at the right place toi have the code work

    since the very same code was working liek a charm on apache 1.3 / PHP4 in my .htaccess

    the mistake most likely is in a more global level in apache2 config
    either httpd.conf
    or
    default_server.conf (SuSE Linux 10.2 uses the subfolder structure of trhe apache2 config folders

    Nintendo
    honestly nintendo - i was hoping you wold come to this thread - i know you have lots of experience :)

    here the full code for one of the major pages

    this code is placed into .htaccess - created by the gallery2 software after detection of the flderstructure - i have EXACTLY to the point the same folder-structure as before, thats why I opted for a root server to facilitate the moving of ten thousands of forum, blog, scripts and gallery files ...

     
    hans, Oct 27, 2006 IP
  6. Shoemoney

    Shoemoney $

    Messages:
    4,474
    Likes Received:
    588
    Best Answers:
    0
    Trophy Points:
    295
    #6
    i dont think its a matter of your code.. i just think you might not have the server configured to see the .htaccess

    check your httpd.conf or apache2.conf depending on what flavor os your running you should have ALLOWOVERRIDE for whatever directory your using.
     
    Shoemoney, Oct 27, 2006 IP
  7. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #7
    Try this test to see if it works.... domain.com/.htaccess with index.php being what ever domain.com/index.xxx is.

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^wacko\.html$ index.php [L]

    Then domain.com/wacko.html should show the index page.

    I've never used %1, %2, %3....but $1, $2, $3....

    Is the

    RewriteCond %{THE_REQUEST}

    line where you're telling it how you want the new URLs?

    RewriteRule . /photography

    is where it goes. I hardly ever use the RewriteCond stuff.
     
    Nintendo, Oct 27, 2006 IP
  8. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #8
    Shoemoney

    i fully agree and i think i pointed that out clearly enough (hopfully ) that MYSELF i belief NOT having ocnfigured apache2 fully and/or correctly in regard to mod_rewrite stuff - the mod_rewirte code is mâuto made by gallery2 SW and the people there are fine professionals and have one of the globe largest gallery OS SW package ( see Google for "gallery" it ranks #1) ... I am sure the mistake is mine in the basic apache2 config

    at least very recently I got it to do the rewirte stuff
    kriyayoga.com > www.kriyayoga.com using mod_rewrite in .htaccess
    thats my first step toward success
    step by step :)

    hence at least on domain / some rewrite starts to work
    as of today the photo_gallery is disabled in maintenance mode - i have to reinstall clean new SW package before testing can continue asap

    Nintendo

    I just did your test
    it goes nowhere but to my custom 404 page

    the rewrite code = base of the gallery is
    /photography/photo_gallery/
     
    hans, Oct 27, 2006 IP
  9. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #9
    If the code was at domain.com/.htaccess with index.php being what ever domain.com/index.xxx is and domain.com/wacko.html didn't show the index page, then it looks like you don't have mod-rewrite right now!! It's not gallery2, it's apache.
     
    Nintendo, Oct 27, 2006 IP
  10. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #10
    I agree its NOT gallery2 code problem

    its apache2 problem and since its my root srver - its ME the problem :)

    but

    the kriyayoga.com to www.kriyayoga.com rewrite part already works now

    it did NOT at the very beginning days ago
    then i cleaned up my apache2 confg and redid some from reading howtos and forums

    but you are right its apache2 stuff - the question is what part of the apache2 config does all the rewrite stuff in a correct way

    the other qquestion is how many options I have to mess it up myself by doing WHAT wrong ?

    the mod_rewrite is loaded as you can see on the phpü.info link provide in my first post

    it must be loaded - the domain rewirte woking is should proof at least that the module is loaded

    may be the sequence in which various options are used in the global httpd config ??


    since in apache docu it usually states where an option or parameter can be used
    i wanted to have all possible config in the global config file
    default_server.conf

    rather than all over the site in .htaccess

    but when I moved my domain rewrite OUT of the global http conf file
    and moved it to /.htaccess
    then it worked ...

    so may be I have the code later on DIS-abled that is contained earlier in the global conf ??
     
    hans, Oct 27, 2006 IP
  11. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #11
    So were you able to get the test code to work when it was in an .htaccess file? I don't know how to make apache stuff work. I just know how to change URLs, redirect, and force the www on to the domain URLs.
     
    Nintendo, Oct 27, 2006 IP
  12. 1EightT

    1EightT Guest

    Messages:
    2,646
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    0
    #12
    this is a known bug between php and apache 2. I've got a couple customers using apache 2 and mod rewrite is completely broken. I'm sticking to apache 1.3. I spent almost 3 days recompiling different versions of php and different configs, but have found no solution.
     
    1EightT, Oct 27, 2006 IP
  13. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #13
    Nintendo

    I remember a few days ago you recommended another guy to go to webmasterworld forum - saying that the mod_rewrite king is there ...
    I smiled when I saw this

    fact is that I think the mod_rewrite king is HERE in DP forum

    your code for testing is right
    an di just noticed by checking my browser cache what URL I typed in for your wacko.html

    and i saw that I have miss-typed it to wacki.html

    now i redid the test and your wacko.html redirects correctly to my index.html :)

    what i never did in earlier days attemps is to add the

    Options +Indexes
    Options +FollowSymlinks

    because i had in the global apache conf clearly
    options multiview All

    and according to my understanding
    All includes All except multiview that needs to be added explicitely

    NOW however with this two additional lines in the
    .htaccess
    your code works = hence the mod_rewrite is supposed to work as well. I have still the gallery to reinstall first before testing live.

    for the moment i have all rewrite stuff in the .htaccess again since it appears that I somehow blocked the rewrite rules inside the global apache conf.

    I let you know as soon as it is live online again.
    thanks for your highly appreciated and fast help.
    I was studying the past 2-3 weeks dozens of hrs all kinds of docu without result.

    1EightT

    my previous host 1and1.com (USA) had for each domain a httpd.conf for the apache 1.3.x

    and that complete config file was looing very simple and straightforward to me and all the rewrite rules that i foudn from anywhere in the web always worked easily.

    one of the key difference in at least my default SuSE 10.1 Linux apache config is ( i belief it is common apache2 ) - besides the complex folder structure we now have in apache2 config

    all my global config was set to

    allowoverride None

    and for the mod_rewrite missing were the apparently important 2 options nintendo had in his example
    Options +Indexes
    Options +FollowSymlinks

    on apache 1.3 i nowwhere saw the above 2 lines added in .htaccess NOR in ghe apache httpd.conf

    hence it seems apache2 is more restrictively compiled and missing features need to be added by loading modules and activating by proper options.

    In the previous apache 1.3 i also nowhere saw the "modul-tags" like
    <IfModule mod_rewrite.c>

    </IfModule>

    while in apache2 it appears often in docs - I yet have to study and learn when and why to use and when NOT.

    in my domain redirect I use the rewrite code INSIDE those above tags
    in the .htaccess

    while the code provided by Nintendo has been added plain as is into .htaccess file.

    when i added Nintendo's code inside the same tag - ABOVE the existing domain rewrite code and replacing the [L] by [NC,OR] tag it caused a 500 error

    honestly I dont know what [NC,OR] is for - but NOT for last - that's [L]
    i copied [NC,OR] from my otherwise working set of rules for hotlinking rewrites ...

    BTW

    i still have the test file UP at domain /
    - i just replaced the "wacko" by the nick of our true mod_rewrite king .html
    it redirects correctly to index.html
    also the combination
    kriyayoga.com/"add_the_nickname_of_our_mod_rewrite-king.html as a filename.html and it
    will redirect to my www domain/index.html

    hence i belief the problem is solved
    final confirmation will be soon

    re PHP and mod_rewrite

    the gallery2 SW has 2 built in options for SEO friendly URL rewrite
    1. option mod_rewrite
    2. option PHP pathinfo

    both work equally and perfectly with the gallery
    I have NO idea which of the 2 methods is less resrouce intense

    the
    Options +Indexes
    Options +FollowSymlinks


    stuff missing in my earlier apache 1.3 may also explain why some software - perl AND PHP sometimes failed to fully autodetect the complete absolute serverpath of its location within the web space. I may think that my host - an dothers as well - may have the customers' data somewhere else and link them into webspace - with the above options missing the HIGHEST folder most of the time got LOST in the path-autodetection an dhad to be added manually.
     
    hans, Oct 27, 2006 IP
  14. 1EightT

    1EightT Guest

    Messages:
    2,646
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    0
    #14
    thanks for the observations. I'll trythis out on our clients machines and see if it finally works.
     
    1EightT, Oct 28, 2006 IP
  15. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #15
    i got today the full rewrite rules working for the gallery SW
    all i did now was to add the two options

    Options +Indexes
    Options +FollowSymlinks


    on each of the gallery-paths first gallery-folder in the .htaccess - all works now as before with apache 1.3
     
    hans, Oct 28, 2006 IP
  16. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #16
    I myself had to use those two codes for it to work. I'm using Apache 2.0.46.
     
    Nintendo, Oct 28, 2006 IP
  17. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #17
    thanks for sharing your expertise nintento
    now after many days of reading and trial and error i finally can move on with the remainder of work involved in mvoing from shared hosting to root server
    btw
    as a result of your recommendation to the other guy recently to ask WM forum
    i once in my life cross posted the same problem at WM forum
    with zero response until now

    :)

    i never matters who the king is - it matters who knows to solve problems in real life
     
    hans, Oct 28, 2006 IP
  18. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #18
    What known bug ? Is there a bug report in either Apache or PHP's bug trackers ?

    My company uses PHP 4 and 5 on Apache 1.3.x, 2.0.x and 2.2.x and we've had no problems at all with rewrites not working.

    We have, on the other hand, had no end of troubles with the PHP4 to PHP5 upgrade and even more problems with the PHP 5.1.6 to PHP 5.2 upgrade. It will be painful, but it's necessary.

    Dave.
     
    Ladadadada, Oct 6, 2007 IP