PDA

View Full Version : Rewriting URL's


Jimerson
May 31st, 2006, 02:07
I recently purchased a cheat code site and I am trying to figure out the best way to rewite the url's

The URL's currently look like:
/index.php?module=cheats&cheat=13372

From what little I know about seo all the search engines will read is index.php and stop there.

As there is around 72,000 cheats on the site. I thought it would be to my advantage to have the pages indexed.

My content is recieved from a database on another site so I am somewhat limited on what I can do.


I do have variables that I can use to put the game title, console, etc..

Can anyone give me some suggestions on how to start?

Thanks,
Jim

sea otter
May 31st, 2006, 02:40
okay, to start...

do you want the incoming url to look like this?

/cheats/13372

instead of /index.php?module=cheats&cheat=13372

Jimerson
May 31st, 2006, 02:45
That is fine if its easy to do and it looks good :)

Thanks,
Jim

sea otter
May 31st, 2006, 02:47
ok, i'll whip up a mod_rewrite rule.

sea otter
May 31st, 2006, 02:58
Put this in a file named .htaccess in your site's root directory:


RewriteEngine On
RewriteBase /


RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^cheats/([a-zA-Z0-9_]*)$ index.php?module=cheats&cheat=$1 [L,QSA]
RewriteRule ^cheats/([a-zA-Z0-9_]*)/$ index.php?module=cheats&cheat=$1 [L,QSA]


I just tested it and it works, but mod_rewrite can be squirrelly, so...

OH, and it also works with a trailing slash, so

/cheats/12345/

works as well.

Allowable characters in "cheats" are a-z A-Z 0-9 and _

Jimerson
June 1st, 2006, 00:26
Thank you so much :)

-Jim