Reputation: 2737
im into SEO and friendly URL's and im trying to create a rule in my htacess file and i need help...
Basically, i have a list of alphabet letters. If the users selects one letter, the db will show all the lyrics that starts with that letter...
so if i click C, there will be a list of lyrics and the the first is 'Car and blues'
So, from this
htpp://www.website.com/lyrics.php?letter=C
i want to do this:
http://www.website.com/lyrics/C/
so far, this is what i have
RewriteRule ^lyrics/$ /lyrics.php?letter=$1 [L]
the rule should be smart enough to pick everything that comes after 'lyrics', in between the 2 slashes, and not what comes after...
Thanks
Upvotes: 2
Views: 114
Reputation: 3217
the rule should be smart enough to pick everything that comes after 'lyrics', in between the 2 slashes, and not what comes after...
I'd suggest you look into using regular expressions to format your url. See this link
Upvotes: 0
Reputation: 54729
the rule should be smart enough to pick everything that comes after 'lyrics', in between the 2 slashes, and not what comes after...
Your rule as it stands is looking for exactly lyrics/
with no possibility of anything before or after it (as defined by the ^
and $
).
Assuming you're using letters A-Z in only capitals, you can use this:
RewriteRule ^lyrics/([A-Z])/?$ /lyrics.php?letter=$1 [L]
This will look for a single capital letter after the lyrics/
and send that value to the rewrite URL and also match both cases of having a trailing /
or not.
Upvotes: 4