clean urls

I'd like to have urls like this:

http://mysite.com/blah where the first path part is dynamic.

http://mysite.com/blah would forward to http://mysite.com/so…ntroller?q=blah

things like this work fine:

http://mysite.com/q/blah

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.

Thanks,

Jeff

You may write the following rule:



'<q>'=>'some_controller'


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

http://example.com/blah

but not

http://example.com/blah/blah

Seems to be working fine now.