我只想到路由我的网址,就像
一样 http://localhost/codeigniter_cup_myth/index.php/adminController/mainAccount
如果是
那就太好了 http://localhost/codeigniter_cup_myth/Accounts/mainAccount
在我的网络应用程序中路由URL时应该从哪里开始?
答案 0 :(得分:3)
路由定义如下:
$route['product/:num'] = "catalog/product_lookup";
其中product
/ anynumber
是您的网址:http://www.example.com/product/234。第二部分是控制器/方法。我们在这里讨论的URL将调用目录控制器的product_lookup方法。
$route['accounts/mainaccount'] = "adminController/mainAccount"
会触发您正在寻找的东西。有关更多示例,请查看CodeIgniter User Guide。
我使用此.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
允许访问任何实际存在的文件,其他所有文件都将路由到CI。
答案 1 :(得分:2)
另外,添加如下内容:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
到您的.htaccess文件将摆脱index.php部分
答案 2 :(得分:1)
woo url路由功能: