Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 761
0 Users 5 Guests Online
Forum Index » PHP + MySQL » .htaccess mod_rewrite
Posted on Sunday 15th February 2009 at 06:18 PM
Dalez
templates/default/images/noavatar.png's Avatar
Junior Member
On my site, i want to make the URLs cleaner and nicer to use.

Atm i have: http://mysite.com/index.php?page=play&id=217
And what i want: http://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
templates/default/images/noavatar.png's Avatar
Senior Member
Code
RewriteEngine On
RewriteRule ^games/([^/]*)/([^/]*)/$ /index.php?page=$1&id=$2 [L]
RewriteRule ^games/([^/]*)/([^/]*)$ /index.php?page=$1&id=$2 [L]


http://www.generateit.net/mod-rewrite/
Posted on Sunday 15th February 2009 at 07:54 PM
Dalez
templates/default/images/noavatar.png's Avatar
Junior Member
Doesn't work ;[

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

Thanks, Dalez.
Posted on Sunday 15th February 2009 at 07:58 PM
UrbanTwitch
templates/default/images/noavatar.png's Avatar
Senior Member
It should work. :S
Use the generator.
Posted on Sunday 15th February 2009 at 08:07 PM
Dalez
templates/default/images/noavatar.png's Avatar
Junior Member
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
templates/default/images/noavatar.png's Avatar
Senior Member
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 ;)
Posted on Wednesday 18th February 2 at 12:34 PM
Dalez
templates/default/images/noavatar.png's Avatar
Junior Member
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 2 at 01:49 PM
Adam981
templates/default/images/noavatar.png's Avatar
Junior Member
do you use "?page" or do u user a different thing where "page" would be?
Posted on Thursday 19th February 20 at 07:21 PM
Dalez
templates/default/images/noavatar.png's Avatar
Junior Member
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.