Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP CodeIgniter开始URL路由_Php_Codeigniter_Url Routing - Fatal编程技术网

使用PHP CodeIgniter开始URL路由

使用PHP CodeIgniter开始URL路由,php,codeigniter,url-routing,Php,Codeigniter,Url Routing,我只是想路由我的网址,就像 http://localhost/codeigniter_cup_myth/index.php/adminController/mainAccount 如果是的话,那就太好了 http://localhost/codeigniter_cup_myth/Accounts/mainAccount 在web应用程序中路由URL时,应从何处开始?路由的定义如下: $route['product/:num'] = "catalog/product_lookup"; 其中pro

我只是想路由我的网址,就像

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

如果是的话,那就太好了

http://localhost/codeigniter_cup_myth/Accounts/mainAccount


在web应用程序中路由URL时,应从何处开始?

路由的定义如下:

$route['product/:num'] = "catalog/product_lookup";
其中
product
/
anynumber
是您的URL:。第二部分是控制器/方法。我们在这里讨论的URL将调用catalog controller的product_查找方法

$route['accounts/mainaccount'] = "adminController/mainAccount"
你要找的东西会被炒了。更多示例请查看CodeIgniter

我使用这个
.htaccess

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

允许访问任何物理上存在的文件,所有其他文件都被路由到CI。

路由定义如下:

$route['product/:num'] = "catalog/product_lookup";
其中
product
/
anynumber
是您的URL:。第二部分是控制器/方法。我们在这里讨论的URL将调用catalog controller的product_查找方法

$route['accounts/mainaccount'] = "adminController/mainAccount"
你要找的东西会被炒了。更多示例请查看CodeIgniter

我使用这个
.htaccess

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

它允许访问任何物理上存在的文件,所有其他文件都被路由到CI。

此外,还添加了如下内容:

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

在.htaccess文件中,还将删除index.php部分,添加如下内容:

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

到您的.htaccess文件将删除index.php部分

您可以检查woo url路由组件

woo url路由功能:

  • 易于将自定义和动态路由url添加到路由集合
  • 易于创建限制与路径匹配的URL的结构
  • 在路线比赛中支持catchall风格
  • 在浏览器地址栏中直接键入URL地址时,使用路由调试器在路由集合中显示路由匹配状态
  • 创建自定义路由处理程序以处理与路由集合中特定路由匹配的URL
    你可以检查woo url路由组件

    woo url路由功能:

  • 易于将自定义和动态路由url添加到路由集合
  • 易于创建限制与路径匹配的URL的结构
  • 在路线比赛中支持catchall风格
  • 在浏览器地址栏中直接键入URL地址时,使用路由调试器在路由集合中显示路由匹配状态
  • 创建自定义路由处理程序以处理与路由集合中特定路由匹配的URL