0

I am trying to come up with the best URL scheme for my site for a plugin I am writing and am coming up against several collisions and road blocks.

The standard URL's look like

1 http://<mysite>/forums/misc.php?mytip=show_list
2 http://<mysite>/forums/misc.php?mytip=show_rounds&id=8
3 http://<mysite>/forums/misc.php?mytip=sign_up&id=8
4 http://<mysite>/forums/misc.php?mytip=show_games&id=8&round_id=123
5 http://<mysite>/forums/misc.php?mytip=leaderboard&id=8
6 http://<mysite>/forums/misc.php?mytip=leaderboard_detail&id=8&user=2&round_id=123
7 http://<mysite>/forums/misc.php?mytip=show_games&id=8&round_id=123&saved=1

Now I wanted to rewrite them to look like

http://<mysite>/tipping-comp/<title of tipping comp>_<id>/<mytip>/<round_name>_round_id

So for example these would look something like

1 http://<mysite>/tipping-comp/show_list 
2 http://<mysite>/tipping-comp/dans-footy-tipping-2013_8/show_rounds/ 
3 http://<mysite>/tipping-comp/dans-footy-tipping-2013_8/sign-up/ 
4 http://<mysite>/tipping-comp/dans-footy-tipping-2013_8/show_games/round-1_184/
5 http://<mysite>/tipping-comp/dans-footy-tipping-2013_8/leaderboard/ 
6 http://<mysite>/tipping-comp/dans-footy-tipping-2013_8/leaderboard_detail/round-1_184/user-2
7 http://<mysite>/tipping-comp/dans-footy-tipping-2013_8/show_games/round-1_184/1

The only reason I am using an underscore is because I was having even more issues where I had names like above where it had a number, then it had the ID. Preferebly I would want all underscores or all dashes.

Is this the best URL scheme for what I am trying to do or would it be better with something that just had slashes like http:///tipping-competition/show_games/8/round_id/184/1

I figure the scheme i am using is the most keyword rich without going over the top and also slightly easier for my users to remember.

I just keep running into 404's or errors because some of the URL's collide with others.

Can anyone help me write a rewrite rule for these?

The collisions I get are with the following rules

 RewriteRule ^tipping-competition/([^/]*)/([^/]*)/([^/]*)\.html$ misc.php?id=$2&mytipper=$3 [L,QSA]

    #round_id added
    RewriteRule ^tipping-competition/([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$ misc.php?id=$2&round_id=$3&mytipper=$4 [L,QSA]

These interrupt each other

Zong
  • 6,160
  • 5
  • 32
  • 46
Dannymh
  • 149
  • 1
  • 11
  • If you do a search for 'mod_rewrite URL routing' you should find lots of examples. Can you edit into your question the rules you currently have? You may find turning on logging in mod_rewrite may help. – halfer Jun 05 '13 at 07:48
  • Thanks have added it in there. – Dannymh Jun 06 '13 at 06:14

1 Answers1

0

My collisions were due to other code. I was able to achieve what I was looking for with the following rules

#standard rewrite rule for getting the list of comps
RewriteRule ^tipping-competition\.html$ misc.php?mytipper=show_list [L,QSA]
#rule for showing selected comp rounds
RewriteRule ^tipping-competition/([^/]*)/([^/]*)/([^/]*)\.html$ misc.php?id=$2&mytipper=$3 [L,QSA]

#round_id added 
RewriteRule ^tipping-competition/([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$ misc.php?id=$2&round_id=$3&mytipper=$4 [L,QSA]
Dannymh
  • 149
  • 1
  • 11