mod_rewrite configuration

Discussion in 'Apache' started by manouche, Apr 3, 2009.

  1. #1
    I have CentOS 5 on Linux. Apache was compiled and set up by someone else. I want to use mod_rewrite. The httpd.conf file has this:

    LoadModule rewrite_module modules/mod_rewrite.so

    I also added this:

    AddModule mod_rewrite.c

    When I restart Apache, it says

    Invalid command 'AddModule', perhaps misspelled or defined by a module not included in the server configuration.

    If I do httpd -l, it doesn't show mod_rewrite as being compiled into Apache. So, does that mean that I have to recompile apache, or is there some other way of getting the mod_rewrite to load?

    Thanks.
     
    manouche, Apr 3, 2009 IP
  2. kailash

    kailash Well-Known Member

    Messages:
    1,248
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    190
    #2
    kailash, Apr 3, 2009 IP
  3. manouche

    manouche Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you. I have already read those and done what it says.

    I still get the error message when trying to restart apache.
     
    manouche, Apr 3, 2009 IP
  4. kailash

    kailash Well-Known Member

    Messages:
    1,248
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    190
    #4
    Then I think you will need to recompile Apache on your server as the module is missing.

    Kailash
     
    kailash, Apr 3, 2009 IP
  5. manouche

    manouche Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for your reply.

    I had tried to enable mod_rewrite in httpd.conf, but it wouldn't allow me to restart apache, so I assumed it wasn't compiled.

    I am running CentOS 5.2, apache 2.2.3, which was installed with CentOS and updated via yum.

    I have this: /usr/lib/httpd/modules/mod_rewrite.so

    If I do httpd -l, it shows:

    Compiled in modules:
    core.c
    prefork.c
    http_core.c
    mod_so.c

    So, my question is, how do I recompile apache with mod_rewrite? I tried to use apxs, but it couldn't find mod_rewrite.c, so I assume that I need to install and configure from source.

    Should I remove the current apache via yum or rpm and then download the newest version of apache that I can configure from source with mod_rewrite, then update via yum?
     
    manouche, Apr 9, 2009 IP