how to change this url

Discuss practical ways rearrange URLs using mod_rewrite.

how to change this url

Postby celebritywallpaper.us » Sun Dec 14, 2008 7:09 pm

Hi

my url look like this

Code: Select all
http://www.mydomain.com/game.php?f=580&a=hello%world


is possible to change to
Code: Select all
http://www.mydomain.com/game/580/hello-world



580 is a unique id number (pull from database)

Thanks advance

p.s.

this is what i have in my htacess
Code: Select all
AddType x-mapp-php5 .php
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?f= [NC]
RewriteCond %{HTTP_REFERER} !^(http://(www\.)?mydomain\.com(/.*)?)?$ [NC]
RewriteRule ^game\.php$ - [NC,F,L]

RewriteRule ^([0-9]+)/free_game_([_A-Za-z0-9-]+)\.html$          /file.php?f=$1 [L]
RewriteRule ^([0-9]+)/free_game_([_A-Za-z0-9-]+)\.html$          /game.php?f=$1 [L]
RewriteRule ^([0-9]+)/free_game_([_A-Za-z0-9-]+)/?$              /browse.php?c=$1 [L]
RewriteRule ^([0-9]+)/free_game_([_A-Za-z0-9-]+)/([0-9]+)\.html$ /browse.php?c=$1&page=$3 [L]
RewriteRule ^profile/([0-9]+)/(.*).html /profile.php?u=$1 [L]
RewriteRule ^page/([0-9]+).html /page.php?p=$1 [L]
celebritywallpaper.us
 
Posts: 41
Joined: Sat Feb 03, 2007 6:27 am

Postby richardk » Mon Dec 15, 2008 8:41 am

Try
Code: Select all
AddType x-mapp-php5 .php
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?f= [NC]
RewriteCond %{HTTP_REFERER} !^(http://(www\.)?mydomain\.com(/.*)?)?$ [NC]
RewriteRule ^game\.php$ - [NC,F,L]

RewriteRule ^([0-9]+)/free_game_([_A-Za-z0-9-]+)\.html$          /file.php?f=$1           [L]
RewriteRule ^([0-9]+)/free_game_([_A-Za-z0-9-]+)\.html$          /game.php?f=$1           [L]
RewriteRule ^([0-9]+)/free_game_([_A-Za-z0-9-]+)/?$              /browse.php?c=$1         [L]
RewriteRule ^([0-9]+)/free_game_([_A-Za-z0-9-]+)/([0-9]+)\.html$ /browse.php?c=$1&page=$3 [L]

RewriteRule ^game/([0-9]+)/([^/]+)/?$                            /game.php?f=$1&a=$2      [L]
RewriteRule ^page/([0-9]+)\.html                                 /page.php?p=$1           [L]
RewriteRule ^profile/([0-9]+)/.+\.html                           /profile.php?u=$1        [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 2 guests

cron