Listing all available controller names in the rule. That is, “if param doesn’t look like one of known controller names then it’s a param for item/index”
Modifying default routing rules so that all params starting with, say, ‘c_’ are controller names. All the rest is params.
That is, “if param equals to c_…, then it’s a controller name, otherwise is a param”.
Using virtual ‘folders’, like ‘/c/something’ = controller, “/something” is a param.
I already understand the way how it could work but the Items are user created items, so they could be a few thousand (but they are unique though), I just store them in my DB and want to get a Detailview of these items with example.com/Itemname.
The major problem is, I should declare the rule in my config/main like u said: "/something.html = item/index?name=something (as param name)", but I have no idea how I can declare them automatically
'<controller:site|news|...|user>/<action:\w+>' => '<controller>/<action>', // this rule intercepts all the controllers you have
'<name:\w+>' => 'item/index' // this rule will activate if passed param doesn't look like controller name
Bad thing is you cannot have items named like controllers in this case.
'<name:\w+>\.html' => 'item/index'
In this case all urls like /something.html, /another.html will be processed by item/index.
So, some things to remember:
URL rules are just old plain regexps
Rules are tested from the top
Parser will stop when it finds matching rule.
That’s why you should place more specific rules above less specific ones.
yes, my .htaccess is located in protected/.htaccess and looks like:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
Rquested URL:
localhost/project/itemname
Also tested it with the example of the CUrlManager: