Apache rewrite - optional parameters?
Posted
by
Mayhem
on Server Fault
See other posts from Server Fault
or by Mayhem
Published on 2011-01-11T20:19:03Z
Indexed on
2011/01/11
20:55 UTC
Read the original article
Hit count: 212
I'm creating SEO friendly urls for my news page.
My links look like this :
www.site.com/1234/the-pretty-url-string/
RewriteRule ^([^/])/([^/])/$ /news.php?sid=$1&url=$2 [L]
This works great, but I like to have more flexability.
I want to be able to accept urls like :
www.site.com/1234
www.site.com/1234/
so then I can do some php $GET's and figure out if anything is missing - and 301 to the proper URL of my choice. I would like the &url=$2 to be optional.
© Server Fault or respective owner