2010-04-06 136 views
0

我只是想路由我的网址是像开始使用URL路由与PHP笨

http://localhost/codeigniter_cup_myth/index.php/adminController/mainAccount

,这将是相当不错的,如果它是

http://localhost/codeigniter_cup_myth/Accounts/mainAccount

凡应我在我的Web应用程序中路由URL时开始?

回答

2

此外,添加类似:

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt) 
RewriteRule ^(.*)$ /index.php/$1 [L] 

到你的.htaccess文件将摆脱index.php的部分

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。

+0

很好,它帮助我... – chhameed 2011-10-18 12:04:22

1

ü可以检查宇URL路由组件

http://code.google.com/p/woo/

woo url路由功能:

  1. 轻松添加自定义和动态路由URL来路由集合。
  2. 易于创建限制匹配修补路线的URL的约束。
  3. 在路线匹配中支持catchall风格。
  4. 直接在浏览器地址栏中输入URL地址时,使用路由调试器显示路由集合中的路由匹配状态。
  5. 创建自定义路由处理程序来处理匹配路由集合中特定路由的URL。