clean urls

I'd like to have urls like this: where the first path part is dynamic. would forward to…ntroller?q=blah

things like this work fine:

it's ONLY when the first part of the URI is dynamic.

i've tried specifying rules in the url manager, but they don't seem to work if the first path part is dynamic.

any ideas?

even rewrites seem to work improperly…perhaps because yii is relying on script_uri or some other server variables that won't get translated on a rewrite.

RewriteRule ^/([^/])+/?$ /en/o/q/$1 [NC,L]  doesn't work but

RewriteRule ^/([^/])+/?$ /en/o/q/$1 [R=302,NC,L] works fine.

I'm stuck, I'd appreciate any help. I'm new to Yii, and I've been struggling to fix this.



You may write the following rule:


Note, however, such a rule would match most incoming URLs. So you should put it as the last rule.

Hmm…doesn't seem to work, still getting a 404

What 404 error are you getting? Is it from Yii or from Apache? If the latter, you need to configure your Apache correctly.

Ah, ok. i finally got it, thank you.

/<q:([^/]+)>/?' => '/my_controller/<q>'

I did it like this, so that it only matches

but not

Seems to be working fine now.