Home > Debian, Debian GNU/Linux, HowTo, Linux, Linux Helps, PHP, Programming Help, ubuntu > how to enable mod_rewrite in apache2.2 (debian/ubuntu)

how to enable mod_rewrite in apache2.2 (debian/ubuntu)

Number of View :8961

Here i am going to describe how to enable mod_rewrite in apache2.2 -specaily for debian.

In default installion of apache2.2 on debian never enable mod_rewrite default. So you may need to enable .

First install the apache2.2 with this command :
debian user please use “su” before start this process
ubuntu user please use “sudo su” before start this process

apt-get install apache2 (it will install apache 2.2)

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

updatedb
locate mod_rewrite.so

it will found in “/usr/lib/apache2/modules”

new apache follow some folders to enable and desuable mods.
so now do this:

cd /etc/apache2/mods-enabled
touch rewrite.load
gedit rewrite.load (you may use any editor to edit this file)

now paste this following line

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

Then edit /etc/apache2/sites-available/000-default

Find the following

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

and change it to

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

and finally restart Apache

/etc/init.d/apache2 restart

OK, you done :D

don’t forget to comment, if it works or not.

thanks.

if you like my post, please tweet it, so other also can see this post.

Popularity: 100% [?]

  • Share/Bookmark

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

  1. July 16th, 2007 at 00:08 | #1

    Whoa!!

    Excellent work Lavlu, much appreciated. This was one of my major problem even few days ago. I just think why didnt you write this article that time.

    :D

    Very good work. Keep it on.

    [Reply]

  2. ebzao
    July 24th, 2007 at 15:03 | #2

    Or more simpler, just do :
    sudo a2enmod rewrite && sudo invoke-rc.d apache2 restart

    [Reply]

  3. July 24th, 2007 at 15:42 | #3

    thanks ebzao. it works :)

    [Reply]

  4. August 19th, 2007 at 04:48 | #4

    Worked like a charm! Thanks for posting this. :)

    [Reply]

  5. adeng
    September 17th, 2007 at 22:37 | #5

    thank bro…it works…

    [Reply]

  6. Javed
    October 25th, 2007 at 09:03 | #6

    Dear Lavluda

    I want pdf of your how to move your php development environment to linux (Debian/Ubuntu) .

    [Reply]

  7. Ivan
    January 8th, 2008 at 00:38 | #7

    Thanks!! Simple and elegant solution!

    [Reply]

  8. January 8th, 2008 at 02:41 | #8

    Excellent!!, finally find perfect and simple solution..

    Thanks!
    Thanks a lot.

    [Reply]

  9. varun
    February 3rd, 2008 at 10:11 | #9

    hey, thanks a lot man. Great job, couldn’t have been put simpler

    [Reply]

  10. April 24th, 2008 at 18:41 | #10

    Thank you very much it works ;) One comment. I’ve found you through google and google sais to me that you are dangerous here is the link look yourself http://www.google.gr/interstitial?url=http://www.lavluda.com/2007/07/15/how-to-enable-mod_rewrite-in-apache22-debian/

    I don’t think that your blog is dangerous. You can complain about that.

    [Reply]

  11. cockhead
    April 28th, 2008 at 22:45 | #11

    thank you very much :)

    [Reply]

  12. May 5th, 2008 at 16:28 | #12

    Works like a charm! Enabled it on Ubuntu 8.04 Server. Thanks!!

    [Reply]

  13. May 17th, 2008 at 04:32 | #13

    Thnx Thnx :D
    it realy worx :D

    [Reply]

  14. May 18th, 2008 at 19:36 | #14

    /etc/apache2/sites-avalible/000-default is /etc/apache2/sites-available/000-default or /etc/apache2/sites-available/default

    [Reply]

  15. May 19th, 2008 at 13:05 | #15

    thanks saltedlight, it was typing mistake :(

    fixed

    [Reply]

  16. Assaf
    May 27th, 2008 at 19:48 | #16

    Works!!!

    [Reply]

  17. June 3rd, 2008 at 20:30 | #17

    Thank you sir. Very succinct! Much appreciated.

    [Reply]

  18. Daz Williams
    June 3rd, 2008 at 23:33 | #18

    Thank you soooo much !!!!

    Worked first time, brilliant!!!!!!

    [Reply]

  19. Brian
    June 10th, 2008 at 14:27 | #19

    Thank you much! Perfect!

    [Reply]

  20. June 24th, 2008 at 23:46 | #20

    Excellent work, a person knowing very little about installing apache in linux could do it without any difficulty. and yes it worked..!!

    Thanks

    [Reply]

  21. RobIII
    June 29th, 2008 at 02:17 | #21

    Jeez.. You have no idea how glad I am i found this. I have been struggling with linux for a few days now. No idea why everything has to be this hard.

    [Reply]

  22. binary
    July 3rd, 2008 at 19:15 | #22

    Are you serious?

    Never heard about a2enmod command?

    #a2enmod rewrite
    #/etc/init.d/apache2 restart

    [Reply]

  23. July 3rd, 2008 at 21:08 | #23

    a2enmod will only work for apache2 default modules. what about if you compiled apache2 ?

    [Reply]

  24. Harsh
    July 17th, 2008 at 14:40 | #24

    Thanku very much yaar, i was searchin for this only thing for last 2 days…..Thanx a lot.

    [Reply]

  25. Harsh
    July 17th, 2008 at 21:59 | #25

    how to activate mod rewrite in CentOS ??
    plzz rply faast i m in danger

    [Reply]

  26. Nikolaj
    July 20th, 2008 at 20:22 | #26

    Very important to say that before you apply rewrite rules you need to say in the site configuration RewriteEngine On

    so the rewrite configuration example looks like this:

    RewriteEngine On

    # allow only for https!
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^/svn(.*) https://%{SERVER_NAME}/svn$1 [R,L]

    [Reply]

  27. tesi
    July 21st, 2008 at 19:19 | #27

    nice, it helps me a lot … but …
    when I try to change AllowOverride None to All, I get the external error and I cannot access my page…Any ideas I’d appreciate so much

    [Reply]

  28. tesi
    July 21st, 2008 at 19:21 | #28

    sorry…500 Internal error :(

    [Reply]

  29. tesi
    July 22nd, 2008 at 13:29 | #29

    I solved this by setting virtual host :) nice

    [Reply]

  30. Carlos
    July 27th, 2008 at 20:41 | #30

    Excelent! it really works.

    I tried because webmedia explorer requires it: http://www.webmediaexplorer.com

    [Reply]

  31. August 12th, 2008 at 04:07 | #31

    Very well done! it worked for me, thanks.

    [Reply]

  32. noname
    August 26th, 2008 at 16:29 | #32

    tanks a lot !! ;)

    [Reply]

  33. August 31st, 2008 at 04:29 | #33

    This could be achieved more easily by symlinking from /etc/apache2/mods-available/rewrite.load (this will also work with any of the other modules that have a file in mods-available).
    :-)

    [Reply]

  34. sas
    September 22nd, 2008 at 19:47 | #34

    this was the only tutorial that made my htaccess files work. thank you very much. good order and good explanation and descriptions.
    thanks…

    [Reply]

  35. Robert
    October 19th, 2008 at 18:35 | #35

    I saw many tutorial but yours works perfectly :) Good work Lavlu!

    [Reply]

  36. cigraphics
    October 29th, 2008 at 01:45 | #36

    Thanks a lot i’ve forgot about the AllowOverride All that was my problem

    [Reply]

  37. Akerman
    November 10th, 2008 at 17:19 | #37

    Most tutorials in regards of ‘mod_rewrite’ out there today, even at Apache site are often referring to older versions, so from that perspective it’s nice with a fresh tutorial.

    However if you are reading this then you should be aware of the following:

    The ‘Enabled’ directory is to contain Links into ‘Available’ directory. Doing anything else is stepping away from the intended server structure. So copy the ‘rewrite.load’ as a link from the ‘Available’ directory, into the ‘Enabled’ directory. No need to edit anything!

    The ’000-default’ is your Apache2 server default file changes here are very global. The edit above actually opens up for the use of ex:’.htaccess’ files in the whole site.
    Normally you leave this file alone and make the appropriate changes at a lower level. Like in the ‘apache2.conf’ which is the normal place for server wide alterations.
    Just a tip…

    [Reply]

  38. November 12th, 2008 at 20:28 | #38

    Thanks!

    [Reply]

  39. delon
    December 9th, 2008 at 08:15 | #39

    thanks a lot! :D

    [Reply]

  40. syabend
    December 23rd, 2008 at 18:58 | #40

    Thanks man, it works like a charm. Thanks to this tutorial i’ve enabled the “Clean URLs” option in Drupal.

    [Reply]

  41. Don
    January 22nd, 2009 at 13:32 | #41

    THANKS!!! I’d been racking my brains trying to get my .htaccess file working. It was full of Rewrite directives. Then I found your explanation. Worked perfectly.

    Thanks, again.

    [Reply]

  42. May 1st, 2009 at 08:34 | #42

    whoaa…its work..thanks…but when i check the mods loaded by apache using apache2ctl -l , mod_rewrite isn’t on the list..but after all it works :p .thanks.

    [Reply]

  43. paul
    May 15th, 2009 at 02:47 | #43

    maque, my impression is that to see the loaded modules you should do apache2ctl -M

    …and BTW Lavluda, it worked for me as well. But I’d like to know why.

    Is there a good book re Apache 2.0 somewhere? The difference between Apache 1.x and 2.x is significant re implementation. It’s much more convoluted; more confusing. So before I make my site public, I’d like to know that I haven’t compromised security in any way.

    [Reply]

  44. paul
    May 15th, 2009 at 22:27 | #44

    This is a follow-up to my post yesterday…

    I spoke too soon. After the tweak, my other non-Drupal sites were no longer available.

    The odd thing is that after I reset everything to the initial Drupal (ie, post-install) settings, clean-urls still worked and my other non-Drupal sites were available once more.

    My system is Linux debian 2.6.26-2-amd64 (Lenny). The bottom line is, in my case, the tweak did not work.

    [Reply]

  45. May 29th, 2009 at 16:10 | #45

    I could not enable the clean URL on a test copy of a Drupal site.

    With this tuto it works.

    Thank you

    [Reply]

  46. June 13th, 2009 at 05:10 | #46

    Thanks a lot
    worked like a charm!
    as you already know!

    [Reply]

  47. June 29th, 2009 at 23:23 | #47

    Thank You!
    Great Job!
    Thanks,thanks,thanks!

    [Reply]

  48. aaronlborg
    July 2nd, 2009 at 11:31 | #48

    totally worked and i had my doubts.

    many thanks.

    [Reply]

  49. DaveWut
    July 7th, 2009 at 10:51 | #49

    YOU SAVE MY LIFE!! Lol!
    All of this because of a simple line change!!

    [Reply]

  50. July 12th, 2009 at 16:33 | #50

    it worked file. in addition i also create a symlink in mods-enables to mods-availables/rewrite.load

    [Reply]

Comment pages
1 2 3 95
  1. August 4th, 2007 at 23:43 | #1
  2. August 29th, 2007 at 21:11 | #2
  3. August 27th, 2008 at 18:21 | #3
  4. October 27th, 2008 at 13:06 | #4
  5. August 23rd, 2010 at 23:13 | #5