Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating SEO friendly urls for my news page.

My links look like this :

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 :

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.

share|improve this question

This works for me:

RewriteRule ^/([^/]+)(?:/([^/]+))?/?$ /news.php?sid=$1&url=$2 [L]
share|improve this answer
hmm .. no luck with that. I test different url's and nothing parsed. – Brian Smith Jan 11 '11 at 20:43
I edited my original answer after testing it :). Let me know if that works for you. – bgould Jan 11 '11 at 21:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.