Rewrite rule index.php?/controller/method/param to /controller/method/param
I need a rewrite rule for this url
http://localhost/~user/frame/lib/index.php?/controller/method/12/22/
How can i rewrite it that i can call it like this
http://localhost/~user/f开发者_JAVA技巧rame/lib/controller/method/12/22/
What is the rewrite rule for the above problem? I hope i could explain my question clear.
Try this rule:
RewriteRule $2 !^index\.php$
RewriteRule ^(/~[^/]+/[^/]+/[^/]+)(/.*)? $1/index.php?$2
Depending on where you want to use this rule (my suggestion is meant for the server/virtual host configuration), you may need to remove the contextual path prefix from the pattern. So if you want to use the rule in the .htaccess file in /~user/:
RewriteRule $2 !^index\.php$
RewriteRule ^([^/]+/[^/]+)(/.*)? $1/index.php?$2
Or if in /~user/frame/lib/:
RewriteRule $0 !^index\.php$
RewriteRule .* index.php?/$0
RewriteRule ^(.*)lib/(.*)$ / $1lib/index.php?/$2
That's the simplest way, but not the most robust as it might screw with other URLs. So it's worth checking thoroughly, or posting your entire .htaccess file.
精彩评论