How to enable mod_rewrite in Apache on Ubuntu

To enable mod_rewrite in Apache on Ubuntu run:

sudo a2enmod rewrite

Open /etc/apache2/sites-enabled/000-default in an editor (for example Nano)

sudo nano /etc/apache2/sites-enabled/000-default
and change
AllowOverride None
to

AllowOverride All

restart Apache:

sudo service apache2 restart

mod_rewrite module is enabled.






  1. Dilip
    2012-10-16 11:42:25
    jc /     Great Article!
    We have Magento 1.6 installed in a sub-directory. We've coiepd .htaccess and index.php to the root directory. So we have 2 .htaccess files:
    /.htaccess
    /magento/.htaccess
    The site works fine except for this index.php in the url. Does anyone have any insight on how to remove it when your installation is in a sub-directory.
    Ive already verified that:
    1. httpd.conf's Allow Override = All
    2. System->Config->Web->Use Web Server Rewrites = Yes
    3. System->Config->Web->Use Secure URLs in Frontend = Yes
    In /.htaccess RewriteBase /magento/
    In /magento/.htaccess #RewriteBase (commented out)
    Thanks!
  1. unixowl
    2012-10-16 12:14:26
    Hi
    1. you don't need .htaccess in the root directory;
    2. in the /magento/.htaccess you need something like this:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /magento/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /magento/index.php [L]
    </IfModule>

Got a comment?

captcha =

Categories

  1. System (20)
    1. FreeBSD (5)
    2. Linux (9)
  2. Email (2)
  3. DNS (2)
  4. Databases (1)
  5. WebServer (27)
 
Copyright © 2012-2015 HowToUnix - *nix Howtos and Tutorials
All Rights Reserved.