View Single Post
  #2 (permalink)  
Old 11-26-2008, 10:16 AM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,648
wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9
Default Re: Search engine friendly urls

Try:

RewriteRule ^/services/(.*)$ /services.php?id=$1 [L]

In the first portion of the rule, the question mark has a different meaning than it does in the second portion. In the first portion, it is used to denote the end of the URI. In the second portion, it denotes a variable. The text you want to store in a variable should be enclosed in parenthesis. In this case, I used .*, which is a regular expression. The dot matches any single character, while the asterisk matches any number of characters. If the only valid character is a single digit number, the following rule should work instead:

RewriteRule ^/services/[1-9]$ /services.php?id=$1 [L]

If the rule should work on any number, from one to four digits, you could use this:

RewriteRule ^/services/[0-9]{1,4}$ /services.php?id=$1 [L]
__________________
The best way to learn anything, is to question everything.
Reply With Quote