Dale's Weblog

looking back it was easy.
Monday 06 February

mod_rewrite

Posted by dale on Thu, 26 Aug 2004 19:33:39 EST

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:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^archive/blog/newsid/([^/]+)$ /?newsid=$1
RewriteRule ^archive/blog/newsid/([^/]+)/$ /?newsid=$1

</IfModule>

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.

This posted was edited: Thu, 26 Aug 2004 19:55:35 EST
Below are the comments for this news item

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

1: Comment by Sphinx^ - Thu, 26 Aug 2004 19:53:36 EST


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

2: Comment by S. - Thu, 26 Aug 2004 20:17:11 EST


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

3: Comment by dale - Thu, 26 Aug 2004 20:47:07 EST


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?

4: Comment by swylie - Sat, 28 Aug 2004 10:22:31 EST


BBCode:

urls become clickable

[b]place text in bold[/b]

[i]place text in italics[/i]

[quote]place text in a quote[/quote]

Comments? Please note that all HTML tags are removed from your post.

The URI to TrackBack this entry is: http://www.dalegroup.net//early05/archive/blog/newsid/trackback/92

Comments

Message:

Name (optional):

Email (not shown):

WWW (optional):






Copyright © Michael Dale 2004. Page generated in 0.0072 seconds FreeBSD Powered
Background on style 5 is used from squidfingers How are we going? 3 queries