Bluetrait

Loading
search


Posts:
Comments:

Popular posts

Click here if you are looking for Bluetrait, the weblog software.

Login:

Username:

Password:

mod_rewrite

Posted by Michael Dale on Thu, 26 Aug 2004 7:33 PM

Here google bot, now you can index me!

Let me try and explain what rewriting is:

mod_rewrite is *some what* like DNS in a way.

For example if you type http://www.google.com your computer will look up the ip address for google and then load the page.
Mod_rewrite looks at the url that the user entered and outputs something.

So the user enters:
http://blog.dalegroup.net/archive/blog/newsid/91#comments
My website outputs:
http://blog.dalegroup.net/index.php?newsid=91#comments
Yet the user doesn't see this.

Like DNS you don't see the IP address just the "mask".

That is just a basic example. mod_rewrite is much more/different than that. But hopefully you understand.

Now why is this a good thing? Well google, yahoo and any other bots have issues with ?= and all that stuff meaning that as until now they would have only indexed the front page of this site. Now since my urls don't have ?= etc google should index them and therefore have a hard linked url to that news item. Sweet :)

For anyone who wants to try this on their site the code I use is here:

RewriteEngine On
RewriteBase /
RewriteRule ^archive/blog/newsid/([^/]+)$ /?newsid=$1
RewriteRule ^archive/blog/newsid/([^/]+)/$ /?newsid=$1

If you want me to explain it, email me :)

EDIT: If you have any problems posting comments etc because of the new setup please do let me know. *hint* post something to test it ;)

EDIT2: I also should thank wordpress for giving me the idea. Although I'm not a fan of third party blogging scripts they have some great developers and features.

On Sat, 28 Aug 2004 at 10:22 AM, swylie wrote:

No, I don't have you're money... it's at Bill's house and Bob's house...

Hey! What are you doing with my money in your house Bill?


On Thu, 26 Aug 2004 at 8:17 PM, Stuart wrote:

Hehe, now I can activate mod_rewrite permalink commands on WP. ;)


On Thu, 26 Aug 2004 at 8:47 PM, Michael Dale wrote:

A good quick guide can be found here:
http://www.sitepoint.com/article/guide-url-rewriting/


On Thu, 26 Aug 2004 at 7:53 PM, Kitten wrote:

well you see i read somewhere that a test was needed... so yeah...
oh yeah those two links dale, you would never guess but they are the SAME!! :o


On Mon, 28 Feb 2005 at 6:42 PM, HeatGrave wrote:

Hey I don't know if you'll ever read this or contact me but. Can you email me at firegraves at gmail dot com and tell me how exactly I would get this to work on my index.php that has plenty of urls using ?blah=&blah2= etc.