You are currently browsing the archives for the Server category.

Categories

Archive for the 'Server' Category

Search Engine friendly URLs using apache’s mod_rewrite

Tuesday, October 30th, 2007

In my last tutorial i described how to use PHP for SE friendly URLs. This time its inverse. Here you will get to know how to use Apache’s mod_rewrite for SE friendly URLs. Here we go:

Installation and Enabling mod_rewrite (Skip this if you are not the server administrator)

First on a *NIX machine, you would have to compile the module with appropriate options. This module is usually shipped with apache; but in case you want to upgrade, etc, etc.

After compiling it, to add it to the list of modules so that apache (httpd) will load it during startup use these:

apache/httpd 1.3.x :

LoadModule rewrite_module modules/mod_rewrite.so

AddModule mod_rewrite.c

apache/httpd 2.2.x :

LoadModule rewrite_module modules/mod_rewrite.so

——————-

Configuring Mod_Rewrite in httpd.conf OR .htaccess :

Now, for example there is a URL with you like ” something.com/abcd/pqrs/tpop/index.php ”

you could simply make it something.com/file.html by using this in httpd.conf OR .htaccess :

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^file.html /abcd/pqrs/tpop/index.php

—–

You can specify unlimited no. of RewriteRules.

The syntax is:

RewriteRule <^false URL/Alias required> <Original URL>

Notice the space between the two URLs!! Don’t mix up them else it won’t work!!

Now the question arises that “What do I do if I have a dynamic system which uses HTTP GET parameters to show the content ? ”

Here’s the solution for this:

consider a url like this: something.com/index.php?do=viewarticle&id=123

and you want a URL like something.com/articles/123

Now, in .htaccess OR httpd.conf use these lines:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^articles/[0-9]+ /index.php?do=viewarticle&id=$1

——-

Here [0-9]+ means there can be any number between 0 and 9 and their repetition.

You can use also a combination of other Regex expressions to achieve your goal. What i tell you here is the tail of an elephant ; the whole elephant is still remaining !!

Well, the syntax for this type is:

Options +FollowSymLinks
RewriteEngine On
RewriteRule <^Fake URL+ Regex> <Original URL and $1 for first regex then $2, & $n for nth regex>

That’s all for now!

Which IP Addresses? Static or Shared?

Monday, June 25th, 2007

To start with, an IP address is a 32-bit numeric address written as four numbers separated by periods. Each of the four numbers can be from 0 to 255, an example would be 192.168.0.5 . The IP address identifies a sender or receiver of information across the Internet. When you request an HTML page or send e-mail the Internet Protocol part of TCP/IP includes your IP address in the message (actually, in each of the packets if more than one is required) and sends it to the IP address of the server to which you wish to communicate. The recipient can see the IP address of the Web page requestor or the e-mail sender and can respond by sending another message using the IP address it received. Each machine on the Internet is assigned a unique IP Address for the purposes of communication.

One term that is familiar to anyone who has their own website, is the phrase “IP Address”. But what is an IP address, and how does it affect your website? And what is the difference between a static and a shared IP Address?

Based on this definition, we can establish that an IP Address is analogous to one’s home address. If someone is to send you mail, they put your address on the front of the envelope, and the mailman delivers it right to your door. IP Addresses work precisely the same way.

There are typically two types of IP Address that can be used in web hosting, Shared or Static. While there is no difference in the IP Address itself, there are some configuration changes on the servers they rest on.

Back to our home address analogy, you might consider a static IP Address to be a stand-alone home. There is only one house who gets mail at that address. You might then consider a shared IP Address to be an apartment building. Many different households get their mail at the same location, and in turn it is distributed to the correct location.

How does this affect you? In most cases, it wont. A static IP Address may be required if you need to have some sort of special access to your website, like SSL or Anonymous FTP. If you have no special requirements, then a shared IP will work under most conditions.

A static IP Address is when a website has their very own IP Address. This means that whether you type in your URL or the IP address of your website, both will bring you to the same page.

A shared IP Address is when multiple websites all share the same IP Address. In this case, the web server does a little bit of extra work when it receives your web request, and passes you to the correct website. Typing in the IP Address will not bring you to your desired website, under most conditions. Why do we need this? I’m sure you noticed that, based on the above definition of an IP Address, that there is a finite number of IP Addresses available before we run out completely. If every single website on the internet had it’s own IP Address, there would be no room for any new ones.

Technorati Tags: , , ,