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.

w2.tar

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

into

auto eth0
iface eth0 inet static
address 192.168.0.116
netmask 255.255.255.0
network 192.168.0.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1

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 192.168.0.116 address, and we also set the namespace and the dns.