0

I have the following url http://www.example.com/teams.php?team_id=12 I want this url to be http://www.example.com/teams-pavilion-boys-varsity-soccer

I have tried the following code

Options +FollowSymlinks    
RewriteEngine on    
RewriteRule ^teams-([0-9a-zA-Z]+)\.html$ teams.php?team_id=$1

Please help me.

Thanks in advance

Sumurai8
  • 20,333
  • 11
  • 66
  • 100
user1639314
  • 19
  • 1
  • 4
  • Instead of "please help me" you could have explained how it's misbehaving, or what you're stumbling on. (Guessing the incomplete charclass / absent url suffix, and expecting numeric id's to materialize from strings.) – mario Aug 31 '12 at 17:14
  • What exactly happened when you tried with your code? Or in other words `what is not working`? – Havelock Aug 31 '12 at 17:14
  • possible duplicate of [RewriteRule will not work in .htaccess file](http://stackoverflow.com/questions/11354509/rewriterule-will-not-work-in-htaccess-file) – mario Aug 31 '12 at 17:15
  • possible duplicate of [rewrite ?id=__ to page title stored in db row](http://stackoverflow.com/questions/7789567/rewrite-id-to-page-title-stored-in-db-row) – mario Aug 31 '12 at 17:16

2 Answers2

0

Check this out:

http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html

I suggest passing the team_name instead of the team_id or you can figure out the team_name from the id. I would even pass in all of the things you need like 'town' 'gender' 'rank' 'sport'

RewriteEngine on
RewriteRule ^teams-([a-zA-Z0-9_-]+)$ teams.php?team_name=$1

Or

RewriteEngine on
RewriteRule ^teams-([a-zA-Z0-9_-]+)-([a-zA-Z0-9_-]+)-([a-zA-Z0-9_-]+)-([a-zA-Z0-9_-]+)$ teams.php?team_town=$1&team_gender=$2&team_rank=$3
Nate-Wilkins
  • 5,364
  • 4
  • 46
  • 61
-1
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -f [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule .* - [L]

RewriteRule ^(.*)$ [URLHERE] [NC]

WATCH THIS

EbinPaulose
  • 1,129
  • 3
  • 14
  • 26