Rewrite rules for apache2.2

22 Aug

Ever got the error – Its showing error like “Oops! This link appears t be broken.” when trying to access an apache project like http://localhost/myproject/home

where myproject lies in  /var/www/

 http://localhost/myproject/index.php/home will work fine

I have write the .htaccess rewrite rules in my project home folder, I got same error this time also.

So here redirection to my project is the problem.

I found we need to Enable mod_rewrite in apache2.2.

For Enable mod_rewrite in apache2.2.

First install the apache2.2,

sudo apt-get install apache2 (this will install apache 2.2)

for the latest system you can enable mod_rewrite using simple command.

a2enmod rewrite

If your system is old system, Please skip the above command.

——————————-Start old system———————————————-

now use locate to find if the is availble on your server



you can find this one in “/usr/lib/apache2/modules”

For new apache follow some folder to enable or disable mods.

cd /etc/apache2/mods-enabled

touch rewrite.load

gedit rewrite.load (you may use any editor to edit  this file)

now past the following line, if the line is already exist.

LoadModule rewrite_module /usr/lib/apache2/modules/

———————————End of old system—————————————–

Then edit /etc/apache2/sites-available/default or /etc/apache2/sites-available/000-default (check which one available on your system)

Find the following

Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all

and change none to all like,

Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all

Create .htaccess file in /var/www/application-folder/


.htaccess file content

RewriteEngine On
RewriteRule ^(application) – [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Finally restart Apache.

/etc/init.d/apache2 restart


/etc/init.d/apache2 stop

/etc/init.d/apache2 start


service apache2 restart

1 Comment

Posted by on August 22, 2011 in Apache, General, PHP, Ubuntu


Tags: , , , , , ,

One response to “Rewrite rules for apache2.2

  1. Loganathan N

    August 3, 2012 at 2:42 pm

    its worked for me ..nice
    thanks 🙂

    while starting server 1 error occur:
    Syntax error on line 6 of /etc/apache2/mods-enabled/jk.load:
    JkRequestLogFormat takes one argument, The mod_jk module request log format string

    After Commenting this line #JkRequestLogFormat “%w %V %T” in jk.load it’s worked nice 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: