I've been puzzling over this none for a while. This is the rewrite rule that I've got at the moment:
Options +FollowSymlinks
DirectoryIndex index.php
RewriteEngine on
RewriteRule ^ext\/(.*)$ index.php/cproposal/key/$1 [NC]
Essentially I'm trying to get
http://localhost/cvc/ext/12445345346
to rewrite to
开发者_如何学运维http://localhost/cvc/index.php/cproposal/key/12445345346
Codeigniter is producing a 404 however. If I change the index.php/cproposal/key/$1
part of the rule to something inane like the Codeigniter license.txt thats found in the directory then it works but anything actually related to Codeigniter itself produces a 404.
Any ideas where I'm going wrong?
mod_rewrite
is great, but Codeigniter already has a built in solution for anything in your Codeigniter application.
Try adding this to your config/routes.php
:
$route['ext/(:num)'] = 'cproposal/key/$1';
This would route requests for:
http://localhost/cvc/ext/{any_number}
to
http://localhost/cvc/cproposal/key/{requested_number}
The index.php
will be optional, and dependent on your CI configuration. In other words, if you're using it already - it will be in the url. If not, it doesn't have to be.
All CI routes may use regular expressions in addition to the built in wildcards (:num)
and (:any)
, so feel free to get creative.
精彩评论