Enable mod_rewrite on openSUSE 11.3 [Linux]

UPDATE (31-08-2013):  This article can also be used for openSUSE 11.4 , openSUSE 12.1, openSUSE 12.2, openSUSE12.3 and Sles 11(server). :)

Last night i installed vanilla forum the latest version(2.0.16), but before that i got into trouble like ‘cannot install vanilla forum because the database host provided is wrong’ some thing like that type of error. Which was basically by .htaccess file. I finally installed it but after some time figuring out the mod_rewrite ghost. Actually it’s quite easy to enable it, there was one thing missing, which took some of my time to figure it out. Lets start how to enable the ghost.

Section-I

1- Open Konsole and become root by su - .

2- I will use vim for editing in konsole, you can use other IDE or GUI application. We need to edit this file /etc/sysconfig/apache2 .

3- Type

vim /etc/sysconfig/apache2

Now apache2 file is open and we need to do some changes in it.

Note: If you are not familiar with vim commands, read it here and be careful to use it. You will need few commands like how to insert(i key), how to quit insert mode(Esc key), how to save the file(:wq [w=write, q=quit]), how to exit the file without save(:q). The link i provided is for reference.

4- Search for APACHE_MODULES and you will see a line some thing like:

APACHE_MODULES=”actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl userdir php5″

Now we will add rewrite at the end of the line and it will become:

APACHE_MODULES=”actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl userdir php5 rewrite”

Save and quit the file with :wq command.

5- Run SuSEconfig to update the Apache configuration files.

6- Restart the server with:

/etc/init.d/apache2 restart

You can check it from PHP info page, create a info.php file and look for rewrite word:

<?php phpinfo(); ?>

If you got it in info.php page, now you can check it with any application you have like WordPress, Vanillaforum, your own files etc. If it works, then skip section-II , Section-III and enjoy.

Section-II

Oh…not working…getting access forbidden page etc etc… don’t panic, there are a little more to change. We need to enable custom Apache .htaccess mod_rewrite now. As you are familiar with vim now, so i am not going to deep now, just the steps which will get you started rewrite.

1- I assume konsole is open in root mode, we need this file to edit now: /etc/apache2/default-server.conf .

2- Type

vim /etc/apache2/default-server.conf

3- Search for AllowOverride , it will be below <Directory “/srv/www/htdocs”> . /srv/www/htdocs can be changed, if you changed your sever root before to some other directory.

4- And change AllowOverride None to AllowOverride All , which will allow you to create custom .htaccess rules.

Save and exit.

5- Run SuSEconfig to update the Apache configuration files.

6- Restart the server with:

/etc/init.d/apache2 restart

That’s all, now you can test it again. If it works, then skip Section-III, if have problems follow section-III which will make sure that now every thing is under control and you can use mod_rewrite.

Section-III

Now time to elaborate that one thing which took my time, it was FollowSymlinks in default-server.conf file. From Section-II step 3(between <Directory ….> tags), search there Options if you see it like Options FollowSymlinks OR Options indexes FollowSymlinks , then its fine, but if not just add this FollowSymlinks , and it will become Options FollowSymlinks .

Follow step 5 and 6 above to restart the server and update the files.

That’s it. Have a lot of fun!

  • http://gibsonsphoto.co.uk Neil

    Excellent! Just worked through this on my web development server and now have mod_rewrite functioning correctly. Thanks!

  • William

    It works! Thanks.

  • Pingback: Can't get Apache to process .htaccess()

  • charliston_m

    Thanks!

  • Dimitar

    Awesome! It works like charm.

  • Pingback: URL rewriting-mod_rewrite()