can't enable mod_rewrite on local ubuntu apache server?

Discussion in 'Apache' started by pythonscript, Aug 18, 2011.

  1. #1
    I have a base install of a LAMP server on my Ubuntu system, and I'm trying to get mod_rewrite working on that local server (the directory of the local site is localhost/project). I added this to my /etc/apache2/httpd.conf file, which was blank before I did so:

    
    <Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
    Satisfy all
    </Directory>
    
    Code (markup):
    and I ran this command to enable mod_rewrite:
    
    sudo a2enmod rewrite
    
    Code (markup):
    I have this code in localhost/project/.htaccess, which works on another site on a shared server elsewhere:
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond $1 !^(index\.php|ajax|css|error|img|js)
    RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
    </IfModule>
    
    Code (markup):
    It's supposed to redirect everything except the listed directories to index.php, which is used as a front controller. However, if I type in http://localhost/project/<any other page> I get a 404 error.

    Any ideas?
    Thank you!
     
    pythonscript, Aug 18, 2011 IP
  2. rndm

    rndm Greenhorn

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    Try this rule just to be sure you don't have a rule problem:
    RewriteEngine On
    RewriteRule ^(google)$ /google2

    If it redirects /google to /google2 you have a problem with your ruleset rather than with config
     
    rndm, Aug 19, 2011 IP