Enabling mod rewrite and htaccess files on Apache

By default, Ubuntu’s Apache will ignore the directives in your .htaccess files.

To enable mod rewrite use a2enmod rewrite on ubuntu.

Now, If you do have access to the main configuration file, You probably should NOT use htacccess files. Having said that, its still always good to learn how to do so.

the enable the htaccess files usage, we need to go to the /etc/apache2/sites-available/default file, and change the AllowOverride directive from none to All.

You then have to restart your server (apache2ctl  restart) for the changes to take place.

Now you can use an htaccess file to check that you task is complete. I have written a simple htaccess file accompanied by two other files, index.html and index.php. The normal Apache behavior is to use the html first. So, you can put these files in a folder and see what you get when you enter the folder.

Then, you can change the file order in the htaccess file, which should change the file you are getting when you enter that directory.


Setting a static ip in ubuntu 12.10

we are going to do so using a text editor and not GUI tools, in case we will need to do this in a script or under command.

We need to edit /etc/network/interfaces file (nano is a great choice).

And change the settings

auto eth0
iface eth0 inet dhcp


auto eth0
iface eth0 inet static

Note the DNS section. in ubuntu 12 you can not use the resolve file (it even says so in the file itself), you must use the interface file.

In the example above, we set the (local) server to address, and we also set the namespace and the dns.