.htaccess mod_rewrite

Posted on Sunday 15th February 2009 at 06:18 PM
Dalez
Dalez's Avatar
On my site, i want to make the URLs cleaner and nicer to use.

Atm i have: https://mysite.com/index.php?page=play&id=217
And what i want: https://mysite.com/games/play/217

In the future, i will be adding videos and pictures too, so i will have: games.php, videos.php and pictures.php

But atm, i only have index.php.

I would like to know how to do this, as i have tried, but it doesn't work.

Heres my code:

Code
RewriteEngine on
RewriteRule ^/(.*)/([0-9]*)$ ?page=$1&id=$2 [L]
RewriteRule ^/(.*)$ index.php?page=$1 [L]


And it doesn't work.

Thanks, Dalez.
Posted on Sunday 15th February 2009 at 06:58 PM
UrbanTwitch
UrbanTwitch's Avatar
Code
RewriteEngine On
RewriteRule ^games/([^/]*)/([^/]*)/$ /index.php?page=$1&id=$2 [L]
RewriteRule ^games/([^/]*)/([^/]*)$ /index.php?page=$1&id=$2 [L]


https://www.generateit.net/mod-rewrite/
Posted on Sunday 15th February 2009 at 07:54 PM
Dalez
Dalez's Avatar
Doesn't work ;[

I go to here: https://mysite.com/games/play/217 and nothing!

Thanks, Dalez.
Posted on Sunday 15th February 2009 at 07:58 PM
UrbanTwitch
UrbanTwitch's Avatar
It should work. :S
Use the generator.
Posted on Sunday 15th February 2009 at 08:07 PM
Dalez
Dalez's Avatar
I have, and i think i've found out what is wrong.

In my code, it needs to get the "play" and the "217" to grab the game. Otherwise, it don't work.

Now, i need to find out a way to resolve this issue, but how?

Any ideas?

Thanks, Dalez.
Posted on Monday 16th February 2009 at 09:19 PM
ShadowMage
ShadowMage's Avatar
So games/play/game_id_here/ ? if so, try this:
Code
RewriteEngine on
RewriteRule ^games/play/([0-9]+)/$ index.php?page=play&id=$1


DUnno, you may have to edit it ;)
failure i sense
Posted on Wednesday 18th February 2009 at 12:34 PM
Dalez
Dalez's Avatar
Ahh, now that works.

But, there is a slight problem...

The game don't show up! Also, the layout doesn't show o.o

Thanks, Dalez.
Posted on Wednesday 18th February 2009 at 01:49 PM
Adam981
Adam981's Avatar
do you use "?page" or do u user a different thing where "page" would be?
Posted on Thursday 19th February 2009 at 07:21 PM
Dalez
Dalez's Avatar
I use ?page, yes.

I just really need help with this ^^

Its for my new updated games website, and i want to get it sorted out soon.

Thanks, Dalez.
Login or register to respond to this forum topic.